Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix linter errors #96

Merged
merged 2 commits into from
Jan 18, 2024
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 Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ $(BIN)/%: | $(BIN) ; $(info $(M) installing $(REPOSITORY)…)

GOLANGCILINT = $(BIN)/golangci-lint
$(BIN)/golangci-lint:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin v1.53.3
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin v1.55.2

GENTOOL = $(BIN)/gentool
$(BIN)/gentool: REPOSITORY=gorm.io/gen/tools/gentool@latest
Expand Down
25 changes: 20 additions & 5 deletions app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str
/* Handle staking state. */

// iterate through redelegations, reset creation height
app.StakingKeeper.IterateRedelegations(ctx, func(_ int64, red stakingtypes.Redelegation) (stop bool) {
err = app.StakingKeeper.IterateRedelegations(ctx, func(_ int64, red stakingtypes.Redelegation) (stop bool) {
for i := range red.Entries {
red.Entries[i].CreationHeight = 0
}
Expand All @@ -175,9 +175,12 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str
}
return false
})
if err != nil {
panic(fmt.Errorf("error when iterating through redelegations: %w", err))
janekolszak marked this conversation as resolved.
Show resolved Hide resolved
}

// iterate through unbonding delegations, reset creation height
app.StakingKeeper.IterateUnbondingDelegations(ctx, func(_ int64, ubd stakingtypes.UnbondingDelegation) (stop bool) {
err = app.StakingKeeper.IterateUnbondingDelegations(ctx, func(_ int64, ubd stakingtypes.UnbondingDelegation) (stop bool) {
for i := range ubd.Entries {
ubd.Entries[i].CreationHeight = 0
}
Expand All @@ -187,6 +190,9 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str
}
return false
})
if err != nil {
panic(fmt.Errorf("error when iterating through unbonding delegations: %w", err))
}

// Iterate through validators by power descending, reset bond heights, and
// update bond intra-tx counters.
Expand All @@ -206,7 +212,10 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str
validator.Jailed = true
}

app.StakingKeeper.SetValidator(ctx, validator)
err = app.StakingKeeper.SetValidator(ctx, validator)
if err != nil {
panic(fmt.Errorf("error when iterating through unbonding delegations: %w", err))
}
counter++
}

Expand All @@ -223,12 +232,18 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str
/* Handle slashing state. */

// reset start height on signing infos
app.SlashingKeeper.IterateValidatorSigningInfos(
err = app.SlashingKeeper.IterateValidatorSigningInfos(
ctx,
func(addr sdk.ConsAddress, info slashingtypes.ValidatorSigningInfo) (stop bool) {
info.StartHeight = 0
app.SlashingKeeper.SetValidatorSigningInfo(ctx, addr, info)
err := app.SlashingKeeper.SetValidatorSigningInfo(ctx, addr, info)
if err != nil {
panic(err)
}
return false
},
)
if err != nil {
panic(err)
}
}
5 changes: 0 additions & 5 deletions app/ibc.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ import (
ibctransferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/v8/modules/core"
ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
ibcconnectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types"
porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types"
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"
Expand All @@ -53,9 +51,6 @@ func (app *App) registerIBCModules() {
}

// register the key tables for legacy param subspaces
keyTable := ibcclienttypes.ParamKeyTable()
keyTable.RegisterParamSet(&ibcconnectiontypes.Params{})
app.ParamsKeeper.Subspace(ibcexported.ModuleName).WithKeyTable(keyTable)
app.ParamsKeeper.Subspace(ibctransfertypes.ModuleName).WithKeyTable(ibctransfertypes.ParamKeyTable())
app.ParamsKeeper.Subspace(icacontrollertypes.SubModuleName).WithKeyTable(icacontrollertypes.ParamKeyTable())
app.ParamsKeeper.Subspace(icahosttypes.SubModuleName).WithKeyTable(icahosttypes.ParamKeyTable())
Expand Down
5 changes: 4 additions & 1 deletion cmd/sequencerd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ func overwriteFlagDefaults(c *cobra.Command, defaults map[string]string) {
set := func(s *pflag.FlagSet, key, val string) {
if f := s.Lookup(key); f != nil {
f.DefValue = val
f.Value.Set(val)
err := f.Value.Set(val)
if err != nil {
panic(err)
}
}
}
for key, val := range defaults {
Expand Down
3 changes: 2 additions & 1 deletion testutil/keeper/sequencer.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ func SequencerKeeper(t testing.TB) (keeper.Keeper, sdk.Context) {
ctx := sdk.NewContext(stateStore, cmtproto.Header{}, false, log.NewNopLogger())

// Initialize params
k.SetParams(ctx, types.DefaultParams())
err := k.SetParams(ctx, types.DefaultParams())
require.NoError(t, err)

return k, ctx
}
3 changes: 1 addition & 2 deletions x/sequencer/ante/tx_interaction_l2_signature_verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
txsigning "github.com/cosmos/cosmos-sdk/types/tx/signing"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
"github.com/cosmos/cosmos-sdk/x/auth/signing"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"

"github.com/warp-contracts/sequencer/x/sequencer/types"
)
Expand Down Expand Up @@ -108,7 +107,7 @@ func verifyNonceAndIncreaseSequence(ctx sdk.Context, ak *authkeeper.AccountKeepe
return nil
}

func getOrCreateAccount(ctx sdk.Context, ak *authkeeper.AccountKeeper, addr sdk.AccAddress, dataItem *types.MsgDataItem) (authtypes.AccountI, error) {
func getOrCreateAccount(ctx sdk.Context, ak *authkeeper.AccountKeeper, addr sdk.AccAddress, dataItem *types.MsgDataItem) (sdk.AccountI, error) {
acc := ak.GetAccount(ctx, addr)

if acc != nil {
Expand Down
3 changes: 1 addition & 2 deletions x/sequencer/ante/tx_interaction_l2_signature_verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"

"github.com/warp-contracts/sequencer/crypto/keys/arweave"
"github.com/warp-contracts/sequencer/crypto/keys/ethereum"
Expand All @@ -36,7 +35,7 @@ func appAndCtx(t *testing.T) (*simapp.SimApp, sdk.Context) {
return app, ctx
}

func addCreatorAccount(t *testing.T, app *simapp.SimApp, ctx sdk.Context, dataItem types.MsgDataItem) authtypes.AccountI {
func addCreatorAccount(t *testing.T, app *simapp.SimApp, ctx sdk.Context, dataItem types.MsgDataItem) sdk.AccountI {
acc := app.AccountKeeper.NewAccountWithAddress(ctx, dataItem.GetSenderAddress())

err := acc.SetSequence(5)
Expand Down
3 changes: 1 addition & 2 deletions x/sequencer/keeper/msg_server_arweave_block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ func keeperCtxAndSrv(t *testing.T) (*keeper.Keeper, sdk.Context, types.MsgServer
func TestArweaveBlockMsgServer(t *testing.T) {
expected := test.ArweaveBlock()
k, ctx, srv := keeperCtxAndSrv(t)
wctx := sdk.WrapSDKContext(ctx)

_, err := srv.ArweaveBlock(wctx, &expected)
_, err := srv.ArweaveBlock(ctx, &expected)
require.NoError(t, err)

result, found := k.GetLastArweaveBlock(ctx)
Expand Down
4 changes: 1 addition & 3 deletions x/sequencer/keeper/msg_server_data_item_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package keeper_test
import (
"testing"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require"

"github.com/warp-contracts/sequencer/x/sequencer/test"
Expand All @@ -13,9 +12,8 @@ func TestDataItemMsgServer(t *testing.T) {
msg := test.ArweaveL2Interaction(t)
msg.SortKey = "1,2,3"
k, ctx, srv := keeperCtxAndSrv(t)
wctx := sdk.WrapSDKContext(ctx)

_, err := srv.DataItem(wctx, &msg)
_, err := srv.DataItem(ctx, &msg)
require.NoError(t, err)

result, found := k.GetPrevSortKey(ctx, "abc")
Expand Down
5 changes: 4 additions & 1 deletion x/sequencer/module/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState,
}

// this line is used by starport scaffolding # genesis/module/init
k.SetParams(ctx, genState.Params)
err := k.SetParams(ctx, genState.Params)
if err != nil {
panic(err)
}
}

// ExportGenesis returns the module's exported genesis
Expand Down
6 changes: 3 additions & 3 deletions x/sequencer/module/simulation.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ var (
)

const (
opWeightMsgDataItem = "op_weight_msg_data_item"
opWeightMsgDataItem = "op_weight_msg_data_item"
defaultWeightMsgDataItem int = 100

opWeightMsgArweaveBlock = "op_weight_msg_arweave_block"
opWeightMsgArweaveBlock = "op_weight_msg_arweave_block"
defaultWeightMsgArweaveBlock int = 100

// this line is used by starport scaffolding # simapp/module/const
Expand All @@ -49,7 +49,7 @@ func (AppModule) GenerateGenesisState(simState *module.SimulationState) {
func (am AppModule) RegisterStoreDecoder(_ simtypes.StoreDecoderRegistry) {}

// ProposalContents doesn't return any content functions for governance proposals.
func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent {
func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalMsg {
return nil
}

Expand Down
Loading