Skip to content

Commit 8a529a3

Browse files
committed
lint
1 parent 86391b2 commit 8a529a3

File tree

24 files changed

+163
-105
lines changed

24 files changed

+163
-105
lines changed

app/ante/ante.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,7 @@ func DefaultSigVerificationGasConsumer(
134134
pubkey := sig.PubKey
135135
switch pubkey := pubkey.(type) {
136136
case *ethsecp256k1.PubKey:
137-
meter.Consume(Secp256k1VerifyCost, "ante verify: eth_secp256k1")
138-
return nil
139-
137+
return meter.Consume(Secp256k1VerifyCost, "ante verify: eth_secp256k1")
140138
case multisig.PubKey:
141139
// Multisig keys
142140
multisignature, ok := sig.Data.(*signing.MultiSignatureData)

app/ante/eip712.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import (
2727
sdk "github.com/cosmos/cosmos-sdk/types"
2828
errortypes "github.com/cosmos/cosmos-sdk/types/errors"
2929
"github.com/cosmos/cosmos-sdk/types/tx/signing"
30-
"github.com/cosmos/cosmos-sdk/x/auth/ante"
3130
authante "github.com/cosmos/cosmos-sdk/x/auth/ante"
3231
"github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"
3332
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
@@ -71,7 +70,9 @@ func NewLegacyCosmosAnteHandlerEip712(ctx context.Context, options HandlerOption
7170
authante.NewSetUpContextDecorator(options.Environment, options.ConsensusKeeper),
7271
authante.NewValidateBasicDecorator(options.Environment),
7372
authante.NewTxTimeoutHeightDecorator(options.Environment),
74-
authante.NewUnorderedTxDecorator(unorderedtx.DefaultMaxTimeoutDuration, options.UnorderedTxManager, options.Environment, ante.DefaultSha256Cost),
73+
authante.NewUnorderedTxDecorator(
74+
unorderedtx.DefaultMaxTimeoutDuration, options.UnorderedTxManager, options.Environment, authante.DefaultSha256Cost,
75+
),
7576
NewMinGasPriceDecorator(options.FeeMarketKeeper, evmDenom, &feemarketParams),
7677
authante.NewValidateMemoDecorator(options.AccountKeeper),
7778
authante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),

app/ante/sigverify.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
txsigning "cosmossdk.io/x/tx/signing"
2323
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
2424
sdk "github.com/cosmos/cosmos-sdk/types"
25-
errortypes "github.com/cosmos/cosmos-sdk/types/errors"
2625
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
2726
authante "github.com/cosmos/cosmos-sdk/x/auth/ante"
2827
secp256k1dcrd "github.com/decred/dcrd/dcrec/secp256k1/v4"
@@ -40,11 +39,11 @@ func VerifyEthSig(msgs []sdk.Msg, signer ethtypes.Signer) error {
4039
for _, msg := range msgs {
4140
msgEthTx, ok := msg.(*evmtypes.MsgEthereumTx)
4241
if !ok {
43-
return errorsmod.Wrapf(errortypes.ErrUnknownRequest, "invalid message type %T, expected %T", msg, (*evmtypes.MsgEthereumTx)(nil))
42+
return errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "invalid message type %T, expected %T", msg, (*evmtypes.MsgEthereumTx)(nil))
4443
}
4544

4645
if err := msgEthTx.VerifySender(signer); err != nil {
47-
return errorsmod.Wrapf(errortypes.ErrorInvalidSigner, "signature verification failed: %s", err.Error())
46+
return errorsmod.Wrapf(sdkerrors.ErrorInvalidSigner, "signature verification failed: %s", err.Error())
4847
}
4948
}
5049

app/app.go

Lines changed: 58 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ var (
173173
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
174174
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
175175
govtypes.ModuleName: {authtypes.Burner},
176-
evmtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, // used for secure addition and subtraction of balance using module account
176+
// used for secure addition and subtraction of balance using module account
177+
evmtypes.ModuleName: {authtypes.Minter, authtypes.Burner},
177178
}
178179

179180
// module accounts that are allowed to receive tokens
@@ -241,7 +242,7 @@ type EthermintApp struct {
241242
sm *module.SimulationManager
242243

243244
// the configurator
244-
configurator module.Configurator
245+
configurator module.Configurator //nolint:staticcheck // SA1019: Configurator is still used in runtime v1.
245246

246247
UnorderedTxManager *unorderedtx.Manager
247248
}
@@ -357,7 +358,11 @@ func NewEthermintApp(
357358
// add keepers
358359
accountsKeeper, err := accounts.NewKeeper(
359360
appCodec,
360-
runtime.NewEnvironment(runtime.NewKVStoreService(keys[accounts.StoreKey]), logger.With(log.ModuleKey, "x/accounts"), runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())),
361+
runtime.NewEnvironment(
362+
runtime.NewKVStoreService(keys[accounts.StoreKey]), logger.With(log.ModuleKey, "x/accounts"),
363+
runtime.EnvWithMsgRouterService(app.MsgServiceRouter()),
364+
runtime.EnvWithQueryRouterService(app.GRPCQueryRouter()),
365+
),
361366
signingCtx.AddressCodec(),
362367
appCodec.InterfaceRegistry(),
363368
txDecoder,
@@ -439,19 +444,25 @@ func NewEthermintApp(
439444
authtypes.FeeCollectorName,
440445
authAddr,
441446
)
442-
if err := app.MintKeeper.SetMintFn(mintkeeper.DefaultMintFn(minttypes.DefaultInflationCalculationFn, app.StakingKeeper, app.MintKeeper)); err != nil {
447+
if err := app.MintKeeper.SetMintFn(
448+
mintkeeper.DefaultMintFn(minttypes.DefaultInflationCalculationFn, app.StakingKeeper, app.MintKeeper),
449+
); err != nil {
443450
panic(err)
444451
}
445452
app.PoolKeeper = poolkeeper.NewKeeper(
446453
appCodec,
447-
runtime.NewEnvironment(runtime.NewKVStoreService(keys[pooltypes.StoreKey]), logger.With(log.ModuleKey, "x/protocolpool")),
454+
runtime.NewEnvironment(
455+
runtime.NewKVStoreService(keys[pooltypes.StoreKey]), logger.With(log.ModuleKey, "x/protocolpool"),
456+
),
448457
app.AuthKeeper,
449458
app.BankKeeper,
450459
authAddr,
451460
)
452461
app.DistrKeeper = distrkeeper.NewKeeper(
453462
appCodec,
454-
runtime.NewEnvironment(runtime.NewKVStoreService(keys[distrtypes.StoreKey]), logger.With(log.ModuleKey, "x/distribution")),
463+
runtime.NewEnvironment(
464+
runtime.NewKVStoreService(keys[distrtypes.StoreKey]), logger.With(log.ModuleKey, "x/distribution"),
465+
),
455466
app.AuthKeeper,
456467
app.BankKeeper,
457468
app.StakingKeeper,
@@ -460,13 +471,17 @@ func NewEthermintApp(
460471
authAddr,
461472
)
462473
app.SlashingKeeper = slashingkeeper.NewKeeper(
463-
runtime.NewEnvironment(runtime.NewKVStoreService(keys[slashingtypes.StoreKey]), logger.With(log.ModuleKey, "x/slashing")),
474+
runtime.NewEnvironment(
475+
runtime.NewKVStoreService(keys[slashingtypes.StoreKey]), logger.With(log.ModuleKey, "x/slashing"),
476+
),
464477
appCodec, app.LegacyAmino(),
465478
app.StakingKeeper,
466479
authAddr,
467480
)
468481
app.FeeGrantKeeper = feegrantkeeper.NewKeeper(
469-
runtime.NewEnvironment(runtime.NewKVStoreService(keys[feegrant.StoreKey]), logger.With(log.ModuleKey, "x/feegrant")),
482+
runtime.NewEnvironment(
483+
runtime.NewKVStoreService(keys[feegrant.StoreKey]), logger.With(log.ModuleKey, "x/feegrant"),
484+
),
470485
appCodec,
471486
app.AuthKeeper.AddressCodec(),
472487
)
@@ -481,8 +496,11 @@ func NewEthermintApp(
481496
}
482497
// set the governance module account as the authority for conducting upgrades
483498
app.UpgradeKeeper = upgradekeeper.NewKeeper(
484-
runtime.NewEnvironment(runtime.NewKVStoreService(keys[upgradetypes.StoreKey]), logger.With(log.ModuleKey, "x/upgrade"),
485-
runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())),
499+
runtime.NewEnvironment(
500+
runtime.NewKVStoreService(keys[upgradetypes.StoreKey]), logger.With(log.ModuleKey, "x/upgrade"),
501+
runtime.EnvWithMsgRouterService(app.MsgServiceRouter()),
502+
runtime.EnvWithQueryRouterService(app.GRPCQueryRouter()),
503+
),
486504
skipUpgradeHeights,
487505
appCodec,
488506
homePath,
@@ -498,9 +516,11 @@ func NewEthermintApp(
498516
),
499517
)
500518
app.AuthzKeeper = authzkeeper.NewKeeper(
501-
runtime.NewEnvironment(runtime.NewKVStoreService(keys[authzkeeper.StoreKey]), logger.With(log.ModuleKey, "x/authz"),
519+
runtime.NewEnvironment(
520+
runtime.NewKVStoreService(keys[authzkeeper.StoreKey]), logger.With(log.ModuleKey, "x/authz"),
502521
runtime.EnvWithMsgRouterService(app.MsgServiceRouter()),
503-
runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())),
522+
runtime.EnvWithQueryRouterService(app.GRPCQueryRouter()),
523+
),
504524
appCodec,
505525
app.AuthKeeper.AddressCodec(),
506526
)
@@ -511,8 +531,11 @@ func NewEthermintApp(
511531
feeMarketSs := app.GetSubspace(feemarkettypes.ModuleName)
512532
app.FeeMarketKeeper = feemarketkeeper.NewKeeper(
513533
appCodec,
514-
runtime.NewEnvironment(runtime.NewKVStoreService(keys[feemarkettypes.StoreKey]), logger.With(log.ModuleKey, "x/feemarket"),
515-
runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())),
534+
runtime.NewEnvironment(
535+
runtime.NewKVStoreService(keys[feemarkettypes.StoreKey]), logger.With(log.ModuleKey, "x/feemarket"),
536+
runtime.EnvWithMsgRouterService(app.MsgServiceRouter()),
537+
runtime.EnvWithQueryRouterService(app.GRPCQueryRouter()),
538+
),
516539
authtypes.NewModuleAddress(govtypes.ModuleName),
517540
feeMarketSs,
518541
)
@@ -521,8 +544,11 @@ func NewEthermintApp(
521544
evmSs := app.GetSubspace(evmtypes.ModuleName)
522545
app.EvmKeeper = evmkeeper.NewKeeper(
523546
appCodec,
524-
runtime.NewEnvironment(runtime.NewKVStoreService(keys[evmtypes.StoreKey]), logger.With(log.ModuleKey, "x/evm"),
525-
runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())),
547+
runtime.NewEnvironment(
548+
runtime.NewKVStoreService(keys[evmtypes.StoreKey]), logger.With(log.ModuleKey, "x/evm"),
549+
runtime.EnvWithMsgRouterService(app.MsgServiceRouter()),
550+
runtime.EnvWithQueryRouterService(app.GRPCQueryRouter()),
551+
),
526552
keys[evmtypes.StoreKey], okeys[evmtypes.ObjectStoreKey], authtypes.NewModuleAddress(govtypes.ModuleName),
527553
app.AuthKeeper, app.BankKeeper, app.StakingKeeper, app.FeeMarketKeeper,
528554
tracer,
@@ -541,9 +567,11 @@ func NewEthermintApp(
541567
*/
542568
govKeeper := govkeeper.NewKeeper(
543569
appCodec,
544-
runtime.NewEnvironment(runtime.NewKVStoreService(keys[govtypes.StoreKey]), logger.With(log.ModuleKey, "x/gov"),
570+
runtime.NewEnvironment(
571+
runtime.NewKVStoreService(keys[govtypes.StoreKey]), logger.With(log.ModuleKey, "x/gov"),
545572
runtime.EnvWithMsgRouterService(app.MsgServiceRouter()),
546-
runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())),
573+
runtime.EnvWithQueryRouterService(app.GRPCQueryRouter()),
574+
),
547575
app.AuthKeeper,
548576
app.BankKeeper,
549577
app.StakingKeeper,
@@ -564,7 +592,11 @@ func NewEthermintApp(
564592
// create evidence keeper with router
565593
evidenceKeeper := evidencekeeper.NewKeeper(
566594
appCodec,
567-
runtime.NewEnvironment(runtime.NewKVStoreService(keys[evidencetypes.StoreKey]), logger.With(log.ModuleKey, "x/evidence"), runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())),
595+
runtime.NewEnvironment(
596+
runtime.NewKVStoreService(keys[evidencetypes.StoreKey]), logger.With(log.ModuleKey, "x/evidence"),
597+
runtime.EnvWithMsgRouterService(app.MsgServiceRouter()),
598+
runtime.EnvWithQueryRouterService(app.GRPCQueryRouter()),
599+
),
568600
app.StakingKeeper,
569601
app.SlashingKeeper,
570602
app.ConsensusParamsKeeper,
@@ -819,7 +851,12 @@ func NewEthermintApp(
819851
// use Ethermint's custom AnteHandler
820852
func (app *EthermintApp) setAnteHandler(txConfig client.TxConfig, maxGasWanted uint64, logger log.Logger) {
821853
anteHandler, err := ante.NewAnteHandler(ante.HandlerOptions{
822-
Environment: runtime.NewEnvironment(nil, logger, runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())), // nil is set as the kvstoreservice to avoid module access
854+
Environment: runtime.NewEnvironment(
855+
nil,
856+
logger,
857+
runtime.EnvWithMsgRouterService(app.MsgServiceRouter()),
858+
runtime.EnvWithQueryRouterService(app.GRPCQueryRouter()),
859+
), // nil is set as the kvstoreservice to avoid module access
823860
ConsensusKeeper: app.ConsensusParamsKeeper,
824861
AccountKeeper: app.AuthKeeper,
825862
AccountAbstractionKeeper: app.AccountsKeeper,
@@ -894,7 +931,7 @@ func (app *EthermintApp) EndBlocker(ctx sdk.Context) (sdk.EndBlock, error) {
894931
return app.ModuleManager.EndBlock(ctx)
895932
}
896933

897-
func (app *EthermintApp) Configurator() module.Configurator {
934+
func (app *EthermintApp) Configurator() module.Configurator { //nolint:staticcheck // SA1019: Configurator is still used in runtime v1.
898935
return app.configurator
899936
}
900937

app/export.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -242,14 +242,17 @@ func (app *EthermintApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAd
242242
/* Handle slashing state. */
243243

244244
// reset start height on signing infos
245-
err = app.SlashingKeeper.ValidatorSigningInfo.Walk(ctx, nil, func(addr sdk.ConsAddress, info slashingtypes.ValidatorSigningInfo) (stop bool, err error) {
246-
info.StartHeight = 0
247-
err = app.SlashingKeeper.ValidatorSigningInfo.Set(ctx, addr, info)
248-
if err != nil {
249-
return true, err
250-
}
251-
return false, nil
252-
})
245+
err = app.SlashingKeeper.ValidatorSigningInfo.Walk(
246+
ctx,
247+
nil,
248+
func(addr sdk.ConsAddress, info slashingtypes.ValidatorSigningInfo) (stop bool, err error) {
249+
info.StartHeight = 0
250+
err = app.SlashingKeeper.ValidatorSigningInfo.Set(ctx, addr, info)
251+
if err != nil {
252+
return true, err
253+
}
254+
return false, nil
255+
})
253256
if err != nil {
254257
panic(err)
255258
}

client/testnet.go

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,14 @@ package client
1919

2020
import (
2121
"bufio"
22+
"crypto/rand"
2223
"encoding/json"
2324
"fmt"
25+
"math/big"
2426
"net"
2527
"os"
2628
"path/filepath"
2729

28-
"github.com/ethereum/go-ethereum/common"
29-
30-
"math/rand"
31-
3230
tmconfig "github.com/cometbft/cometbft/config"
3331
"github.com/cometbft/cometbft/types"
3432
tmtime "github.com/cometbft/cometbft/types/time"
@@ -53,14 +51,13 @@ import (
5351
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
5452
"github.com/cosmos/cosmos-sdk/x/genutil"
5553
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
56-
54+
"github.com/ethereum/go-ethereum/common"
5755
"github.com/evmos/ethermint/crypto/hd"
5856
"github.com/evmos/ethermint/server/config"
5957
srvflags "github.com/evmos/ethermint/server/flags"
58+
"github.com/evmos/ethermint/testutil/network"
6059
ethermint "github.com/evmos/ethermint/types"
6160
evmtypes "github.com/evmos/ethermint/x/evm/types"
62-
63-
"github.com/evmos/ethermint/testutil/network"
6461
)
6562

6663
var (
@@ -114,7 +111,7 @@ func addTestnetFlagsToCmd(cmd *cobra.Command) {
114111

115112
// NewTestnetCmd creates a root testnet command with subcommands to run an in-process testnet or initialize
116113
// validator configuration files for running a multi-validator testnet in a separate process
117-
func NewTestnetCmd(mbm module.Manager, genBalIterator banktypes.GenesisBalancesIterator) *cobra.Command {
114+
func NewTestnetCmd(mbm module.Manager) *cobra.Command {
118115
testnetCmd := &cobra.Command{
119116
Use: "testnet",
120117
Short: "subcommands for starting or configuring local testnets",
@@ -124,13 +121,13 @@ func NewTestnetCmd(mbm module.Manager, genBalIterator banktypes.GenesisBalancesI
124121
}
125122

126123
testnetCmd.AddCommand(testnetStartCmd())
127-
testnetCmd.AddCommand(testnetInitFilesCmd(mbm, genBalIterator))
124+
testnetCmd.AddCommand(testnetInitFilesCmd(mbm))
128125

129126
return testnetCmd
130127
}
131128

132129
// get cmd to initialize all files for tendermint testnet and application
133-
func testnetInitFilesCmd(mbm module.Manager, genBalIterator banktypes.GenesisBalancesIterator) *cobra.Command {
130+
func testnetInitFilesCmd(mbm module.Manager) *cobra.Command {
134131
cmd := &cobra.Command{
135132
Use: "init-files",
136133
Short: "Initialize config directories & files for a multi-validator testnet running locally via separate processes (e.g. Docker Compose or similar)", //nolint:lll
@@ -164,7 +161,7 @@ Example:
164161
args.numValidators, _ = cmd.Flags().GetInt(flagNumValidators)
165162
args.algo, _ = cmd.Flags().GetString(flags.FlagKeyType)
166163

167-
return initTestnetFiles(clientCtx, cmd, serverCtx.Config, mbm, genBalIterator, args)
164+
return initTestnetFiles(clientCtx, cmd, serverCtx.Config, mbm, args)
168165
},
169166
}
170167

@@ -227,11 +224,14 @@ func initTestnetFiles(
227224
cmd *cobra.Command,
228225
nodeConfig *tmconfig.Config,
229226
mbm module.Manager,
230-
genBalIterator banktypes.GenesisBalancesIterator,
231227
args initArgs,
232228
) error {
233229
if args.chainID == "" {
234-
args.chainID = fmt.Sprintf("ethermint_%d-1", rand.Int63n(9999999999999)+1)
230+
i, err := rand.Int(rand.Reader, new(big.Int).SetInt64(int64(9999999999999)))
231+
if err != nil {
232+
return err
233+
}
234+
args.chainID = fmt.Sprintf("ethermint_%d-1", i.Int64()+1)
235235
}
236236

237237
nodeIDs := make([]string, args.numValidators)
@@ -364,12 +364,15 @@ func initTestnetFiles(
364364
}
365365

366366
customAppTemplate, customAppConfig := config.AppConfig(ethermint.AttoPhoton)
367-
srvconfig.SetConfigTemplate(customAppTemplate)
367+
if err := srvconfig.SetConfigTemplate(customAppTemplate); err != nil {
368+
return err
369+
}
368370
if err := sdkserver.InterceptConfigsPreRunHandler(cmd, customAppTemplate, customAppConfig, tmconfig.DefaultConfig()); err != nil {
369371
return err
370372
}
371-
372-
srvconfig.WriteConfigFile(filepath.Join(nodeDir, "config/app.toml"), appConfig)
373+
if err := srvconfig.WriteConfigFile(filepath.Join(nodeDir, "config/app.toml"), appConfig); err != nil {
374+
return err
375+
}
373376
}
374377

375378
if err := initGenFiles(clientCtx, mbm, args.chainID, ethermint.AttoPhoton, genAccounts, genBalances, genFiles, args.numValidators); err != nil {
@@ -378,7 +381,7 @@ func initTestnetFiles(
378381

379382
err := collectGenFiles(
380383
clientCtx, nodeConfig, args.chainID, nodeIDs, valPubKeys, args.numValidators,
381-
args.outputDir, args.nodeDirPrefix, args.nodeDaemonHome, genBalIterator,
384+
args.outputDir, args.nodeDirPrefix, args.nodeDaemonHome,
382385
)
383386
if err != nil {
384387
return err
@@ -465,7 +468,7 @@ func initGenFiles(
465468
func collectGenFiles(
466469
clientCtx client.Context, nodeConfig *tmconfig.Config, chainID string,
467470
nodeIDs []string, valPubKeys []cryptotypes.PubKey, numValidators int,
468-
outputDir, nodeDirPrefix, nodeDaemonHome string, genBalIterator banktypes.GenesisBalancesIterator,
471+
outputDir, nodeDirPrefix, nodeDaemonHome string,
469472
) error {
470473
var appState json.RawMessage
471474
genTime := tmtime.Now()

0 commit comments

Comments
 (0)