From 61260dfda844a4d2f936a385c0e06d58181bd45f Mon Sep 17 00:00:00 2001 From: Thomas Nguy <81727899+thomas-nguy@users.noreply.github.com> Date: Fri, 25 Jun 2021 17:31:57 +0900 Subject: [PATCH] fix linter issues (#184) --- .golangci.yml | 3 +++ app/app.go | 8 ++++---- cmd/ethermintd/flags.go | 8 ++++---- ethereum/rpc/namespaces/eth/api.go | 2 +- ethereum/rpc/namespaces/eth/filters/api.go | 8 ++++---- ethereum/rpc/namespaces/eth/filters/filters.go | 8 ++++---- x/evm/module.go | 2 +- x/evm/types/chain_config.go | 2 +- 8 files changed, 22 insertions(+), 19 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 2d914549..19463f15 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -52,6 +52,9 @@ issues: - text: "ST1003:" linters: - stylecheck + - text: "SA1019:" + linters: + - staticcheck max-issues-per-linter: 10000 max-same-issues: 10000 diff --git a/app/app.go b/app/app.go index 53bfd653..62af7cde 100644 --- a/app/app.go +++ b/app/app.go @@ -162,7 +162,7 @@ var ( var _ simapp.App = (*EthermintApp)(nil) -//var _ server.Application (*EthermintApp)(nil) +// var _ server.Application (*EthermintApp)(nil) // EthermintApp implements an extended ABCI application. It is an application // that may process transactions through Ethereum's EVM running atop of @@ -358,7 +358,7 @@ func NewEthermintApp( // TODO: do properly // NOTE: we may consider parsing `appOpts` inside module constructors. For the moment // we prefer to be more strict in what arguments the modules expect. - //var skipGenesisInvariants = cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants)) + // var skipGenesisInvariants = cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants)) skipGenesisInvariants := true // NOTE: Any module instantiated in the module manager that is later modified @@ -425,10 +425,10 @@ func NewEthermintApp( app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino) app.mm.RegisterServices(module.NewConfigurator(app.MsgServiceRouter(), app.GRPCQueryRouter())) - //add test gRPC service for testing gRPC queries in isolation + // add test gRPC service for testing gRPC queries in isolation // testdata.RegisterTestServiceServer(app.GRPCQueryRouter(), testdata.TestServiceImpl{}) - //create the simulation manager and define the order of the modules for deterministic simulations + // create the simulation manager and define the order of the modules for deterministic simulations //NOTE: this is not required apps that don't use the simulator for fuzz testing // transactions diff --git a/cmd/ethermintd/flags.go b/cmd/ethermintd/flags.go index 7f959660..678bdc07 100644 --- a/cmd/ethermintd/flags.go +++ b/cmd/ethermintd/flags.go @@ -62,16 +62,16 @@ func addTxFlags(cmd *cobra.Command) *cobra.Command { cmd.PersistentFlags().BoolVar(&logJSON, "log-json", false, "Use JSON as the output format of the own logger (default: text)") cmd.PersistentFlags().BoolVar(&evmDebug, "evm-debug", false, "Enable EVM debug traces") cmd.PersistentFlags().StringVar(&logLevel, "log-level", "info", "Sets the level of the own logger (error, warn, info, debug)") - //cmd.PersistentFlags().Bool(flags.FlagTrustNode, true, "Trust connected full node (don't verify proofs for responses)") + // cmd.PersistentFlags().Bool(flags.FlagTrustNode, true, "Trust connected full node (don't verify proofs for responses)") cmd.PersistentFlags().String(flags.FlagKeyringBackend, keyring.BackendFile, "Select keyring's backend") // --gas can accept integers and "simulate" - //cmd.PersistentFlags().Var(&flags.GasFlagVar, "gas", fmt.Sprintf( + // cmd.PersistentFlags().Var(&flags.GasFlagVar, "gas", fmt.Sprintf( // "gas limit to set per-transaction; set to %q to calculate required gas automatically (default %d)", // flags.GasFlagAuto, flags.DefaultGasLimit, - //)) + // )) - //viper.BindPFlag(flags.FlagTrustNode, cmd.Flags().Lookup(flags.FlagTrustNode)) + // viper.BindPFlag(flags.FlagTrustNode, cmd.Flags().Lookup(flags.FlagTrustNode)) // TODO: we need to handle the errors for these, decide if we should return error upward and handle // nolint: errcheck diff --git a/ethereum/rpc/namespaces/eth/api.go b/ethereum/rpc/namespaces/eth/api.go index a9bffd0c..7815089e 100644 --- a/ethereum/rpc/namespaces/eth/api.go +++ b/ethereum/rpc/namespaces/eth/api.go @@ -198,7 +198,7 @@ func (e *PublicAPI) Accounts() ([]common.Address, error) { // BlockNumber returns the current block number. func (e *PublicAPI) BlockNumber() (hexutil.Uint64, error) { - //e.logger.Debugln("eth_blockNumber") + // e.logger.Debugln("eth_blockNumber") return e.backend.BlockNumber() } diff --git a/ethereum/rpc/namespaces/eth/filters/api.go b/ethereum/rpc/namespaces/eth/filters/api.go index 7cd29675..b06471a3 100644 --- a/ethereum/rpc/namespaces/eth/filters/api.go +++ b/ethereum/rpc/namespaces/eth/filters/api.go @@ -22,8 +22,8 @@ import ( evmtypes "github.com/tharsis/ethermint/x/evm/types" ) -// FiltersBackend defines the methods requided by the PublicFilterAPI backend -type FiltersBackend interface { +// Backend defines the methods requided by the PublicFilterAPI backend +type Backend interface { GetBlockByNumber(blockNum types.BlockNumber, fullTx bool) (map[string]interface{}, error) HeaderByNumber(blockNum types.BlockNumber) (*ethtypes.Header, error) HeaderByHash(blockHash common.Hash) (*ethtypes.Header, error) @@ -51,14 +51,14 @@ type filter struct { // PublicFilterAPI offers support to create and manage filters. This will allow external clients to retrieve various // information related to the Ethereum protocol such as blocks, transactions and logs. type PublicFilterAPI struct { - backend FiltersBackend + backend Backend events *EventSystem filtersMu sync.Mutex filters map[rpc.ID]*filter } // NewPublicAPI returns a new PublicFilterAPI instance. -func NewPublicAPI(tmWSClient *rpcclient.WSClient, backend FiltersBackend) *PublicFilterAPI { +func NewPublicAPI(tmWSClient *rpcclient.WSClient, backend Backend) *PublicFilterAPI { api := &PublicFilterAPI{ backend: backend, filters: make(map[rpc.ID]*filter), diff --git a/ethereum/rpc/namespaces/eth/filters/filters.go b/ethereum/rpc/namespaces/eth/filters/filters.go index 9e0c507b..a3329625 100644 --- a/ethereum/rpc/namespaces/eth/filters/filters.go +++ b/ethereum/rpc/namespaces/eth/filters/filters.go @@ -18,21 +18,21 @@ import ( // Filter can be used to retrieve and filter logs. type Filter struct { - backend FiltersBackend + backend Backend criteria filters.FilterCriteria matcher *bloombits.Matcher } // NewBlockFilter creates a new filter which directly inspects the contents of // a block to figure out whether it is interesting or not. -func NewBlockFilter(backend FiltersBackend, criteria filters.FilterCriteria) *Filter { +func NewBlockFilter(backend Backend, criteria filters.FilterCriteria) *Filter { // Create a generic filter and convert it into a block filter return newFilter(backend, criteria, nil) } // NewRangeFilter creates a new filter which uses a bloom filter on blocks to // figure out whether a particular block is interesting or not. -func NewRangeFilter(backend FiltersBackend, begin, end int64, addresses []common.Address, topics [][]common.Hash) *Filter { +func NewRangeFilter(backend Backend, begin, end int64, addresses []common.Address, topics [][]common.Hash) *Filter { // Flatten the address and topic filter clauses into a single bloombits filter // system. Since the bloombits are not positional, nil topics are permitted, // which get flattened into a nil byte slice. @@ -67,7 +67,7 @@ func NewRangeFilter(backend FiltersBackend, begin, end int64, addresses []common } // newFilter returns a new Filter -func newFilter(backend FiltersBackend, criteria filters.FilterCriteria, matcher *bloombits.Matcher) *Filter { +func newFilter(backend Backend, criteria filters.FilterCriteria, matcher *bloombits.Matcher) *Filter { return &Filter{ backend: backend, criteria: criteria, diff --git a/x/evm/module.go b/x/evm/module.go index 53cd4f13..8485aa1e 100644 --- a/x/evm/module.go +++ b/x/evm/module.go @@ -81,7 +81,7 @@ func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) types.RegisterInterfaces(registry) } -//____________________________________________________________________________ +// ____________________________________________________________________________ // AppModule implements an application module for the evm module. type AppModule struct { diff --git a/x/evm/types/chain_config.go b/x/evm/types/chain_config.go index 36dd8085..93b56afc 100644 --- a/x/evm/types/chain_config.go +++ b/x/evm/types/chain_config.go @@ -29,7 +29,7 @@ func (cc ChainConfig) EthereumConfig(chainID *big.Int) *params.ChainConfig { IstanbulBlock: getBlockValue(cc.IstanbulBlock), MuirGlacierBlock: getBlockValue(cc.MuirGlacierBlock), BerlinBlock: getBlockValue(cc.BerlinBlock), - //TODO(xlab): after upgrading ethereum to newer version, this should be set to YoloV2Block + // TODO(xlab): after upgrading ethereum to newer version, this should be set to YoloV2Block YoloV3Block: getBlockValue(cc.YoloV3Block), EWASMBlock: getBlockValue(cc.EWASMBlock), CatalystBlock: getBlockValue(cc.CatalystBlock),