Skip to content

Commit

Permalink
linting 🧹
Browse files Browse the repository at this point in the history
  • Loading branch information
spoo-bar committed May 22, 2024
1 parent f4e6234 commit 01051a2
Show file tree
Hide file tree
Showing 49 changed files with 185 additions and 161 deletions.
3 changes: 2 additions & 1 deletion app/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import (
errorsmod "cosmossdk.io/errors"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmTypes "github.com/CosmWasm/wasmd/x/wasm/types"
"github.com/archway-network/archway/x/cwfees"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
ibcante "github.com/cosmos/ibc-go/v8/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"

"github.com/archway-network/archway/x/cwfees"

rewardsAnte "github.com/archway-network/archway/x/rewards/ante"
rewardsKeeper "github.com/archway-network/archway/x/rewards/keeper"
trackingAnte "github.com/archway-network/archway/x/tracking/ante"
Expand Down
17 changes: 9 additions & 8 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ import (
wasmdKeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmdTypes "github.com/CosmWasm/wasmd/x/wasm/types"
cosmwasm "github.com/CosmWasm/wasmvm"
"github.com/archway-network/archway/app/keepers"
"github.com/archway-network/archway/x/cwfees"
"github.com/archway-network/archway/x/genmsg"
abci "github.com/cometbft/cometbft/abci/types"
tmos "github.com/cometbft/cometbft/libs/os"
cmproto "github.com/cometbft/cometbft/proto/tendermint/types"
Expand Down Expand Up @@ -115,14 +112,16 @@ 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"
ibcclient "github.com/cosmos/ibc-go/v8/modules/core/02-client"
ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/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"
ibccm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"
"github.com/spf13/cast"

"github.com/archway-network/archway/app/keepers"
"github.com/archway-network/archway/x/cwfees"
"github.com/archway-network/archway/x/genmsg"

"github.com/archway-network/archway/wasmbinding"

"github.com/archway-network/archway/x/callback"
Expand Down Expand Up @@ -467,8 +466,7 @@ func NewArchwayApp(
govRouter := govV1Beta1types.NewRouter()
govRouter.
AddRoute(govtypes.RouterKey, govV1Beta1types.ProposalHandler).
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.Keepers.ParamsKeeper)).
AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.Keepers.IBCKeeper.ClientKeeper))
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.Keepers.ParamsKeeper))

// IBC Fee Module keeper
app.Keepers.IBCFeeKeeper = ibcfeekeeper.NewKeeper(
Expand Down Expand Up @@ -872,7 +870,10 @@ func NewArchwayApp(
app.ModuleManager.RegisterInvariants(&app.Keepers.CrisisKeeper)

app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())
app.ModuleManager.RegisterServices(app.configurator)
err = app.ModuleManager.RegisterServices(app.configurator)
if err != nil {
panic(fmt.Errorf("failed to register services: %s", err))
}
app.setupUpgrades()

// create the simulation manager and define the order of the modules for deterministic simulations
Expand Down
8 changes: 5 additions & 3 deletions app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,17 @@ func TestArchwaydExport(t *testing.T) {
stateBytes, err := tmjson.MarshalIndent(genesisState, "", " ")
require.NoError(t, err)

gapp.InitChain(
_, err = gapp.InitChain(
&abci.RequestInitChain{
Validators: []abci.ValidatorUpdate{},
ConsensusParams: simapp.DefaultConsensusParams,
AppStateBytes: stateBytes,
},
)
require.NoError(t, err, "InitChain must not fail")

gapp.Commit()
_, err = gapp.Commit()
require.NoError(t, err, "Commit must not fail")

_, err = gapp.ExportAppStateAndValidators(false, []string{}, []string{})
require.NoError(t, err, "ExportAppStateAndValidators should not have an error")
Expand Down Expand Up @@ -113,7 +115,7 @@ func genesisStateWithValSet(t *testing.T,
bondAmt := sdk.DefaultPowerReduction

for _, val := range valSet.Validators {
pk, err := cryptocodec.FromTmPubKeyInterface(val.PubKey)
pk, err := cryptocodec.FromCmtPubKeyInterface(val.PubKey)
require.NoError(t, err)
pkAny, err := codectypes.NewAnyWithValue(pk)
require.NoError(t, err)
Expand Down
45 changes: 36 additions & 9 deletions app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,17 @@ func (app *ArchwayApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddr
/* Handle fee distribution state. */

// withdraw all validator commission
app.Keepers.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
err := app.Keepers.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
valBz, err := app.Keepers.StakingKeeper.ValidatorAddressCodec().StringToBytes(val.GetOperator())
if err != nil {
panic(err)
}
_, _ = app.Keepers.DistrKeeper.WithdrawValidatorCommission(ctx, valBz) //nolint:errcheck
return false
})
if err != nil {
panic(err)
}

// withdraw all delegator rewards
dels, err := app.Keepers.StakingKeeper.GetAllDelegations(ctx)
Expand Down Expand Up @@ -113,7 +116,7 @@ func (app *ArchwayApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddr
ctx = ctx.WithBlockHeight(0)

// reinitialize all validators
app.Keepers.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
err = app.Keepers.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
valBz, err := app.Keepers.StakingKeeper.ValidatorAddressCodec().StringToBytes(val.GetOperator())
if err != nil {
panic(err)
Expand All @@ -139,6 +142,9 @@ func (app *ArchwayApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddr
}
return false
})
if err != nil {
panic(err)
}

// reinitialize all delegations
for _, del := range dels {
Expand Down Expand Up @@ -166,22 +172,34 @@ func (app *ArchwayApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddr
/* Handle staking state. */

// iterate through redelegations, reset creation height
app.Keepers.StakingKeeper.IterateRedelegations(ctx, func(_ int64, red stakingtypes.Redelegation) (stop bool) {
err = app.Keepers.StakingKeeper.IterateRedelegations(ctx, func(_ int64, red stakingtypes.Redelegation) (stop bool) {
for i := range red.Entries {
red.Entries[i].CreationHeight = 0
}
app.Keepers.StakingKeeper.SetRedelegation(ctx, red)
err := app.Keepers.StakingKeeper.SetRedelegation(ctx, red)
if err != nil {
panic(err)
}
return false
})
if err != nil {
panic(err)
}

// iterate through unbonding delegations, reset creation height
app.Keepers.StakingKeeper.IterateUnbondingDelegations(ctx, func(_ int64, ubd stakingtypes.UnbondingDelegation) (stop bool) {
err = app.Keepers.StakingKeeper.IterateUnbondingDelegations(ctx, func(_ int64, ubd stakingtypes.UnbondingDelegation) (stop bool) {
for i := range ubd.Entries {
ubd.Entries[i].CreationHeight = 0
}
app.Keepers.StakingKeeper.SetUnbondingDelegation(ctx, ubd)
err := app.Keepers.StakingKeeper.SetUnbondingDelegation(ctx, ubd)
if err != nil {
panic(err)
}
return false
})
if err != nil {
panic(err)
}

// Iterate through validators by power descending, reset bond heights, and
// update bond intra-tx counters.
Expand All @@ -201,7 +219,10 @@ func (app *ArchwayApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddr
validator.Jailed = true
}

app.Keepers.StakingKeeper.SetValidator(ctx, validator)
err = app.Keepers.StakingKeeper.SetValidator(ctx, validator)
if err != nil {
panic(err)
}
counter++
}

Expand All @@ -215,12 +236,18 @@ func (app *ArchwayApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddr
/* Handle slashing state. */

// reset start height on signing infos
app.Keepers.SlashingKeeper.IterateValidatorSigningInfos(
err = app.Keepers.SlashingKeeper.IterateValidatorSigningInfos(
ctx,
func(addr sdk.ConsAddress, info slashingtypes.ValidatorSigningInfo) (stop bool) {
info.StartHeight = 0
app.Keepers.SlashingKeeper.SetValidatorSigningInfo(ctx, addr, info)
err := app.Keepers.SlashingKeeper.SetValidatorSigningInfo(ctx, addr, info)
if err != nil {
panic(err)
}
return false
},
)
if err != nil {
panic(err)
}
}
3 changes: 2 additions & 1 deletion app/test_access.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package app

import (
"github.com/archway-network/archway/app/params"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"

"github.com/archway-network/archway/app/params"

"github.com/cosmos/cosmos-sdk/codec"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
Expand Down
3 changes: 2 additions & 1 deletion app/upgrades/4_0_2/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ func (suite *UpgradeTestSuite) TestUpgrade() {
suite.Require().NoError(err)
ctx = ctx.WithBlockHeight(dummyUpgradeHeight)
suite.Require().NotPanics(func() {
suite.archway.GetApp().BeginBlocker(ctx)
_, err = suite.archway.GetApp().BeginBlocker(ctx)
suite.Require().NoError(err)
})

tc.post_upgrade()
Expand Down
2 changes: 1 addition & 1 deletion app/upgrades/6_0_0/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ var Upgrade = upgrades.Upgrade{
case banktypes.ModuleName:
keyTable = banktypes.ParamKeyTable() //nolint:staticcheck
case stakingtypes.ModuleName:
keyTable = stakingtypes.ParamKeyTable()
keyTable = stakingtypes.ParamKeyTable() //nolint:staticcheck
case minttypes.ModuleName:
keyTable = minttypes.ParamKeyTable() //nolint:staticcheck
case distrtypes.ModuleName:
Expand Down
5 changes: 0 additions & 5 deletions cmd/archwayd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,3 @@ func getExpectedLibwasmVersion() (string, error) {
}
return "", fmt.Errorf("unable to detect the expected libwasmvm version")
}

func logExit(code int, format string, args ...interface{}) {
_, _ = fmt.Fprintf(os.Stderr, format, args...)
os.Exit(code)
}
1 change: 0 additions & 1 deletion cmd/archwayd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ func (ac appCreator) newApp(
traceStore io.Writer,
appOpts servertypes.AppOptions,
) servertypes.Application {

var cache storetypes.MultiStorePersistentCache

if cast.ToBool(appOpts.Get(server.FlagInterBlockCache)) {
Expand Down
1 change: 1 addition & 0 deletions e2e/gastracking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"time"

"cosmossdk.io/math"

archway "github.com/archway-network/archway/types"

wasmdTypes "github.com/CosmWasm/wasmd/x/wasm/types"
Expand Down
11 changes: 7 additions & 4 deletions e2e/testing/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
math "cosmossdk.io/math"
storetypes "cosmossdk.io/store/types"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
"github.com/archway-network/archway/app"
abci "github.com/cometbft/cometbft/abci/types"
tmProto "github.com/cometbft/cometbft/proto/tendermint/types"
tmTypes "github.com/cometbft/cometbft/types"
Expand All @@ -36,6 +35,8 @@ import (
"github.com/cosmos/ibc-go/v8/testing/mock"
"github.com/golang/protobuf/proto" //nolint:staticcheck
"github.com/stretchr/testify/require"

"github.com/archway-network/archway/app"
)

var TestAccountAddr = sdk.AccAddress("test")
Expand Down Expand Up @@ -150,7 +151,7 @@ func NewTestChain(t *testing.T, chainIdx int, opts ...interface{}) *TestChain {
stakingValidators := make([]stakingTypes.Validator, 0, len(validatorSet.Validators))
stakingDelegations := make([]stakingTypes.Delegation, 0, len(validatorSet.Validators))
for i, val := range validatorSet.Validators {
valPubKey, err := cryptoCodec.FromTmPubKeyInterface(val.PubKey)
valPubKey, err := cryptoCodec.FromCmtPubKeyInterface(val.PubKey)
require.NoError(t, err)

valPubKeyAny, err := codecTypes.NewAnyWithValue(valPubKey)
Expand Down Expand Up @@ -238,14 +239,15 @@ func NewTestChain(t *testing.T, chainIdx int, opts ...interface{}) *TestChain {
genStateBytes, err := json.MarshalIndent(genState, "", " ")
require.NoError(t, err)

archApp.InitChain(
_, err = archApp.InitChain(
&abci.RequestInitChain{
ChainId: chainid,
Validators: []abci.ValidatorUpdate{},
ConsensusParams: consensusParams,
AppStateBytes: genStateBytes,
},
)
require.NoError(t, err)

// Create a chain and finalize the 1st block
chain := TestChain{
Expand Down Expand Up @@ -394,7 +396,8 @@ func (chain *TestChain) BeginBlock() []abci.Event {
func (chain *TestChain) EndBlock() []abci.Event {
res, err := chain.app.ModuleManager.EndBlock(chain.GetContext())
require.NoError(chain.t, err)
chain.app.Commit()
_, err = chain.app.Commit()
require.NoError(chain.t, err)

return res.Events
}
Expand Down
3 changes: 2 additions & 1 deletion e2e/testing/chain_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package e2eTesting

import (
math "cosmossdk.io/math"
archway "github.com/archway-network/archway/types"
cmproto "github.com/cometbft/cometbft/proto/tendermint/types"
"github.com/cosmos/cosmos-sdk/codec"
mintTypes "github.com/cosmos/cosmos-sdk/x/mint/types"

archway "github.com/archway-network/archway/types"

"github.com/archway-network/archway/app"
rewardsTypes "github.com/archway-network/archway/x/rewards/types"
)
Expand Down
2 changes: 1 addition & 1 deletion e2e/testing/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type grpcClient struct {

func (c grpcClient) Invoke(ctx context.Context, method string, args, reply interface{}, opts ...grpc.CallOption) error {
req := args.(proto.Message)
resp, err := c.app.Query(nil, &abci.RequestQuery{
resp, err := c.app.Query(ctx, &abci.RequestQuery{
Data: c.app.AppCodec().MustMarshal(req),
Path: method,
Height: 0, // TODO: heightened queries
Expand Down
2 changes: 1 addition & 1 deletion interchaintest/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

const (
initialVersion = "v7.0.0" // The last release of the chain. The one the mainnet is running on
initialVersion = "v7.0.1" // The last release of the chain. The one the mainnet is running on
upgradeName = "latest" // The next upgrade name. Should match the upgrade handler.
chainName = "archway"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/collcompat/collcompat.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (store coreKVStore) ReverseIterator(start, end []byte) (store.Iterator, err

type protoMessage[T any] interface {
*T
codec.ProtoMarshaler
proto.Message
}

// ProtoValue inits a collections.ValueCodec for a generic gogo protobuf message.
Expand Down
9 changes: 6 additions & 3 deletions wasmbinding/gov/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,17 @@ func TestGovWASMBindings(t *testing.T) {

proposal, err := govTypes.NewProposal([]sdk.Msg{}, proposalId, ctx.BlockHeader().Time, ctx.BlockHeader().Time.Add(*params.MaxDepositPeriod), "", "Text Proposal", "Description", depositor, false)
require.NoError(t, err)
keeper.SetProposal(ctx, proposal)
err = keeper.SetProposal(ctx, proposal)
require.NoError(t, err)

// Make a deposit
deposit := govTypes.NewDeposit(proposalId, depositor, nil)
keeper.SetDeposit(ctx, deposit)
err = keeper.SetDeposit(ctx, deposit)
require.NoError(t, err)

// Vote
keeper.ActivateVotingPeriod(ctx, proposal)
err = keeper.ActivateVotingPeriod(ctx, proposal)
require.NoError(t, err)
err = keeper.AddVote(ctx, proposalId, voter, govTypes.NewNonSplitVoteOption(govTypes.OptionYes), "")
require.NoError(t, err)

Expand Down
Loading

0 comments on commit 01051a2

Please sign in to comment.