Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
sainoe committed Oct 3, 2023
1 parent 67b8c31 commit 1fd8409
Show file tree
Hide file tree
Showing 15 changed files with 61 additions and 49 deletions.
2 changes: 1 addition & 1 deletion app/provider/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (

autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1"
evidencekeeper "github.com/cosmos/cosmos-sdk/x/evidence/keeper"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
Expand Down Expand Up @@ -67,6 +66,7 @@ import (
distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
"github.com/cosmos/cosmos-sdk/x/evidence"
evidencekeeper "github.com/cosmos/cosmos-sdk/x/evidence/keeper"
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
Expand Down
1 change: 0 additions & 1 deletion app/sovereign/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ import (
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"

// add mint
mint "github.com/cosmos/cosmos-sdk/x/mint"
mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper"
Expand Down
5 changes: 0 additions & 5 deletions tests/e2e/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -1260,11 +1260,6 @@ func (tr TestRun) relayPacketsHermes(
) {
// hermes clear packets ibc0 transfer channel-13
//#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments.
fmt.Println("hermes", "clear", "packets",
"--chain", string(tr.chainConfigs[action.ChainA].ChainId),
"--port", action.Port,
"--channel", "channel-"+fmt.Sprint(action.Channel))

cmd := exec.Command("docker", "exec", tr.containerConfig.InstanceName, "hermes", "clear", "packets",
"--chain", string(tr.chainConfigs[action.ChainA].ChainId),
"--port", action.Port,
Expand Down
1 change: 0 additions & 1 deletion tests/e2e/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@ func (tr TestRun) getRewards(chain ChainID, modelState Rewards) Rewards {
}

func (tr TestRun) getReward(chain ChainID, validator ValidatorID, blockHeight uint, isNativeDenom bool) float64 {

delAddresss := tr.validatorConfigs[validator].DelAddress
if chain != ChainID("provi") && tr.validatorConfigs[validator].UseConsumerKey {
delAddresss = tr.validatorConfigs[validator].ConsumerDelAddress
Expand Down
6 changes: 4 additions & 2 deletions tests/integration/double_vote.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package integration

import (
tmcrypto "github.com/cometbft/cometbft/crypto"
tmtypes "github.com/cometbft/cometbft/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"

tmcrypto "github.com/cometbft/cometbft/crypto"
tmtypes "github.com/cometbft/cometbft/types"

testutil "github.com/cosmos/interchain-security/v3/testutil/crypto"
"github.com/cosmos/interchain-security/v3/x/ccv/provider/types"
)
Expand Down
6 changes: 4 additions & 2 deletions tests/integration/misbehaviour.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package integration
import (
"time"

ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/interchain-security/v3/x/ccv/provider/types"

tmtypes "github.com/cometbft/cometbft/types"
ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"

"github.com/cosmos/interchain-security/v3/x/ccv/provider/types"
)

// TestHandleConsumerMisbehaviour tests that handling a valid misbehaviour,
Expand Down
6 changes: 3 additions & 3 deletions x/ccv/provider/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import (
"fmt"
"strings"

ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
"github.com/spf13/cobra"

tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/version"
ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"

sdk "github.com/cosmos/cosmos-sdk/types"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"

"github.com/cosmos/interchain-security/v3/x/ccv/provider/types"
)
Expand Down
12 changes: 7 additions & 5 deletions x/ccv/provider/keeper/double_vote.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import (
"bytes"
"fmt"

errorsmod "cosmossdk.io/errors"

cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"

tmtypes "github.com/cometbft/cometbft/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"

"github.com/cosmos/interchain-security/v3/x/ccv/provider/types"
ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types"
)
Expand Down Expand Up @@ -67,7 +69,7 @@ func (k Keeper) VerifyDoubleVotingEvidence(
if evidence.VoteA.Height != evidence.VoteB.Height ||
evidence.VoteA.Round != evidence.VoteB.Round ||
evidence.VoteA.Type != evidence.VoteB.Type {
return sdkerrors.Wrapf(
return errorsmod.Wrapf(
ccvtypes.ErrInvalidDoubleVotingEvidence,
"h/r/s does not match: %d/%d/%v vs %d/%d/%v",
evidence.VoteA.Height, evidence.VoteA.Round, evidence.VoteA.Type,
Expand All @@ -76,7 +78,7 @@ func (k Keeper) VerifyDoubleVotingEvidence(

// Addresses must be the same
if !bytes.Equal(evidence.VoteA.ValidatorAddress, evidence.VoteB.ValidatorAddress) {
return sdkerrors.Wrapf(
return errorsmod.Wrapf(
ccvtypes.ErrInvalidDoubleVotingEvidence,
"validator addresses do not match: %X vs %X",
evidence.VoteA.ValidatorAddress,
Expand All @@ -86,7 +88,7 @@ func (k Keeper) VerifyDoubleVotingEvidence(

// BlockIDs must be different
if evidence.VoteA.BlockID.Equals(evidence.VoteB.BlockID) {
return sdkerrors.Wrapf(
return errorsmod.Wrapf(
ccvtypes.ErrInvalidDoubleVotingEvidence,
"block IDs are the same (%v) - not a real duplicate vote",
evidence.VoteA.BlockID,
Expand Down
7 changes: 5 additions & 2 deletions x/ccv/provider/keeper/double_vote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ import (
"testing"
"time"

tmtypes "github.com/cometbft/cometbft/types"
"github.com/stretchr/testify/require"

cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"

tmtypes "github.com/cometbft/cometbft/types"

testutil "github.com/cosmos/interchain-security/v3/testutil/crypto"
testkeeper "github.com/cosmos/interchain-security/v3/testutil/keeper"
"github.com/stretchr/testify/require"
)

func TestVerifyDoubleVotingEvidence(t *testing.T) {
Expand Down
16 changes: 10 additions & 6 deletions x/ccv/provider/keeper/misbehaviour.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ package keeper
import (
"fmt"

tmtypes "github.com/cometbft/cometbft/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"

errorsmod "cosmossdk.io/errors"

sdk "github.com/cosmos/cosmos-sdk/types"

tmtypes "github.com/cometbft/cometbft/types"

"github.com/cosmos/interchain-security/v3/x/ccv/provider/types"
)

Expand Down Expand Up @@ -137,7 +141,7 @@ func headerToLightBlock(h ibctmtypes.Header) (*tmtypes.LightBlock, error) {
func (k Keeper) CheckMisbehaviour(ctx sdk.Context, misbehaviour ibctmtypes.Misbehaviour) error {
clientState, found := k.clientKeeper.GetClientState(ctx, misbehaviour.ClientId)
if !found {
return sdkerrors.Wrapf(ibcclienttypes.ErrClientNotFound, "cannot check misbehaviour for client with ID %s", misbehaviour.ClientId)
return errorsmod.Wrapf(ibcclienttypes.ErrClientNotFound, "cannot check misbehaviour for client with ID %s", misbehaviour.ClientId)
}

clientStore := k.clientKeeper.ClientStore(ctx, misbehaviour.ClientId)
Expand All @@ -146,7 +150,7 @@ func (k Keeper) CheckMisbehaviour(ctx sdk.Context, misbehaviour ibctmtypes.Misbe
// the misbehaviour is for a light client attack and not a time violation,
// see ibc-go/modules/light-clients/07-tendermint/types/misbehaviour_handle.go
if !misbehaviour.Header1.GetHeight().EQ(misbehaviour.Header2.GetHeight()) {
return sdkerrors.Wrap(ibcclienttypes.ErrInvalidMisbehaviour, "headers are not at same height")
return errorsmod.Wrap(ibcclienttypes.ErrInvalidMisbehaviour, "headers are not at same height")
}

// CheckMisbehaviourAndUpdateState verifies the misbehaviour against the trusted consensus states
Expand All @@ -155,7 +159,7 @@ func (k Keeper) CheckMisbehaviour(ctx sdk.Context, misbehaviour ibctmtypes.Misbe
// see ibc-go/modules/light-clients/07-tendermint/types/misbehaviour_handle.go
ok := clientState.CheckForMisbehaviour(ctx, k.cdc, clientStore, &misbehaviour)
if !ok {
return sdkerrors.Wrapf(ibcclienttypes.ErrInvalidMisbehaviour, "invalid misbehaviour for client-id: %s", misbehaviour.ClientId)
return errorsmod.Wrapf(ibcclienttypes.ErrInvalidMisbehaviour, "invalid misbehaviour for client-id: %s", misbehaviour.ClientId)
}

return nil
Expand Down
5 changes: 2 additions & 3 deletions x/ccv/provider/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ import (
"context"
"encoding/base64"

cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"

errorsmod "cosmossdk.io/errors"

tmtypes "github.com/cometbft/cometbft/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

tmprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto"
tmtypes "github.com/cometbft/cometbft/types"

"github.com/cosmos/interchain-security/v3/x/ccv/provider/types"
ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types"
Expand Down
4 changes: 3 additions & 1 deletion x/ccv/provider/keeper/punish_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import (
"fmt"

errorsmod "cosmossdk.io/errors"
"cosmossdk.io/math"

sdk "github.com/cosmos/cosmos-sdk/types"
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

"github.com/cosmos/interchain-security/v3/x/ccv/provider/types"
)

Expand Down Expand Up @@ -50,7 +52,7 @@ func (k Keeper) JailAndTombstoneValidator(ctx sdk.Context, providerAddr types.Pr
// `redelegations`, as well as the current `power` of the validator.
// Note that this method does not perform any slashing.
func (k Keeper) ComputePowerToSlash(ctx sdk.Context, validator stakingtypes.Validator, undelegations []stakingtypes.UnbondingDelegation,
redelegations []stakingtypes.Redelegation, power int64, powerReduction sdk.Int,
redelegations []stakingtypes.Redelegation, power int64, powerReduction math.Int,
) int64 {
// compute the total numbers of tokens currently being undelegated
undelegationsInTokens := sdk.NewInt(0)
Expand Down
22 changes: 12 additions & 10 deletions x/ccv/provider/keeper/punish_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,22 @@ import (
"testing"
"time"

"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"

"cosmossdk.io/math"

codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"

sdk "github.com/cosmos/cosmos-sdk/types"
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

tmtypes "github.com/cometbft/cometbft/types"

cryptotestutil "github.com/cosmos/interchain-security/v3/testutil/crypto"
testkeeper "github.com/cosmos/interchain-security/v3/testutil/keeper"
"github.com/cosmos/interchain-security/v3/x/ccv/provider/types"
"github.com/golang/mock/gomock"

tmtypes "github.com/cometbft/cometbft/types"
"github.com/stretchr/testify/require"
)

// TestJailAndTombstoneValidator tests that the jailing of a validator is only executed
Expand Down Expand Up @@ -190,7 +192,7 @@ func TestComputePowerToSlash(t *testing.T) {
undelegations []stakingtypes.UnbondingDelegation
redelegations []stakingtypes.Redelegation
power int64
powerReduction sdk.Int
powerReduction math.Int
expectedPower int64
}{
{
Expand Down Expand Up @@ -305,7 +307,7 @@ func TestComputePowerToSlash(t *testing.T) {
gomock.InOrder(mocks.MockStakingKeeper.EXPECT().
SlashUnbondingDelegation(gomock.Any(), gomock.Any(), int64(0), sdk.NewDec(1)).
DoAndReturn(
func(_ sdk.Context, undelegation stakingtypes.UnbondingDelegation, _ int64, _ sdk.Dec) sdk.Int {
func(_ sdk.Context, undelegation stakingtypes.UnbondingDelegation, _ int64, _ sdk.Dec) math.Int {
sum := sdk.NewInt(0)
for _, r := range undelegation.Entries {
if r.IsMature(ctx.BlockTime()) {
Expand All @@ -318,7 +320,7 @@ func TestComputePowerToSlash(t *testing.T) {
mocks.MockStakingKeeper.EXPECT().
SlashRedelegation(gomock.Any(), gomock.Any(), gomock.Any(), int64(0), sdk.NewDec(1)).
DoAndReturn(
func(ctx sdk.Context, _ stakingtypes.Validator, redelegation stakingtypes.Redelegation, _ int64, _ sdk.Dec) sdk.Int {
func(ctx sdk.Context, _ stakingtypes.Validator, redelegation stakingtypes.Redelegation, _ int64, _ sdk.Dec) math.Int {
sum := sdk.NewInt(0)
for _, r := range redelegation.Entries {
if r.IsMature(ctx.BlockTime()) {
Expand Down Expand Up @@ -420,7 +422,7 @@ func TestSlashValidator(t *testing.T) {
mocks.MockStakingKeeper.EXPECT().
SlashUnbondingDelegation(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).
DoAndReturn(
func(_ sdk.Context, undelegation stakingtypes.UnbondingDelegation, _ int64, _ sdk.Dec) sdk.Int {
func(_ sdk.Context, undelegation stakingtypes.UnbondingDelegation, _ int64, _ sdk.Dec) math.Int {
sum := sdk.NewInt(0)
for _, r := range undelegation.Entries {
if r.IsMature(ctx.BlockTime()) {
Expand All @@ -433,7 +435,7 @@ func TestSlashValidator(t *testing.T) {
mocks.MockStakingKeeper.EXPECT().
SlashRedelegation(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).
DoAndReturn(
func(_ sdk.Context, _ stakingtypes.Validator, redelegation stakingtypes.Redelegation, _ int64, _ sdk.Dec) sdk.Int {
func(_ sdk.Context, _ stakingtypes.Validator, redelegation stakingtypes.Redelegation, _ int64, _ sdk.Dec) math.Int {
sum := sdk.NewInt(0)
for _, r := range redelegation.Entries {
if r.IsMature(ctx.BlockTime()) {
Expand Down
12 changes: 8 additions & 4 deletions x/ccv/provider/types/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ import (
"fmt"
"strings"

tmtypes "github.com/cometbft/cometbft/proto/tendermint/types"
ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"

errorsmod "cosmossdk.io/errors"

sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"

ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
tmtypes "github.com/cometbft/cometbft/proto/tendermint/types"

ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types"
)

Expand Down Expand Up @@ -121,7 +125,7 @@ func (msg MsgSubmitConsumerMisbehaviour) Type() string {
// Type implements the sdk.Msg interface.
func (msg MsgSubmitConsumerMisbehaviour) ValidateBasic() error {
if msg.Submitter == "" {
return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, msg.Submitter)
return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, msg.Submitter)
}

if err := msg.Misbehaviour.ValidateBasic(); err != nil {
Expand Down Expand Up @@ -161,7 +165,7 @@ func (msg MsgSubmitConsumerDoubleVoting) Type() string {
// Type implements the sdk.Msg interface.
func (msg MsgSubmitConsumerDoubleVoting) ValidateBasic() error {
if msg.Submitter == "" {
return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, msg.Submitter)
return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, msg.Submitter)
}
if msg.DuplicateVoteEvidence == nil {
return fmt.Errorf("double voting evidence cannot be nil")
Expand Down
5 changes: 2 additions & 3 deletions x/ccv/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
auth "github.com/cosmos/cosmos-sdk/x/auth/types"
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
"github.com/cosmos/cosmos-sdk/x/staking/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

abci "github.com/cometbft/cometbft/abci/types"
Expand All @@ -34,8 +33,8 @@ type StakingKeeper interface {
Jail(sdk.Context, sdk.ConsAddress) // jail a validator
Slash(sdk.Context, sdk.ConsAddress, int64, int64, sdk.Dec) math.Int
SlashWithInfractionReason(sdk.Context, sdk.ConsAddress, int64, int64, sdk.Dec, stakingtypes.Infraction) math.Int
SlashUnbondingDelegation(sdk.Context, types.UnbondingDelegation, int64, sdk.Dec) math.Int
SlashRedelegation(sdk.Context, types.Validator, types.Redelegation, int64, sdk.Dec) math.Int
SlashUnbondingDelegation(sdk.Context, stakingtypes.UnbondingDelegation, int64, sdk.Dec) math.Int
SlashRedelegation(sdk.Context, stakingtypes.Validator, stakingtypes.Redelegation, int64, sdk.Dec) math.Int
Unjail(ctx sdk.Context, addr sdk.ConsAddress)
GetValidator(ctx sdk.Context, addr sdk.ValAddress) (validator stakingtypes.Validator, found bool)
IterateLastValidatorPowers(ctx sdk.Context, cb func(addr sdk.ValAddress, power int64) (stop bool))
Expand Down

0 comments on commit 1fd8409

Please sign in to comment.