From 93920799432471116d349f1ccc771b4482fb664c Mon Sep 17 00:00:00 2001 From: anhductn2001 Date: Mon, 28 Aug 2023 12:53:57 +0700 Subject: [PATCH 1/7] upgrade to v5 --- tests/interchaintest/upgrade_chain_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/interchaintest/upgrade_chain_test.go b/tests/interchaintest/upgrade_chain_test.go index 94e26672d..43c594cac 100644 --- a/tests/interchaintest/upgrade_chain_test.go +++ b/tests/interchaintest/upgrade_chain_test.go @@ -20,7 +20,7 @@ const ( func TestCentauriUpgrade(t *testing.T) { repo, version := GetDockerImageInfo() - CosmosChainUpgradeTest(t, repo, version, "v4") + CosmosChainUpgradeTest(t, repo, version, "v5") } func CosmosChainUpgradeTest(t *testing.T, upgradeContainerRepo, upgradeVersion, upgradeName string) { @@ -39,7 +39,7 @@ func CosmosChainUpgradeTest(t *testing.T, upgradeContainerRepo, upgradeVersion, Images: []ibc.DockerImage{ { Repository: "ghcr.io/notional-labs/centauri", - Version: "3.2.3", + Version: "4.5.1", UidGid: "1025:1025", }, }, From a0aaaa3f0cdac100446429c8d7c04b02d8600b4d Mon Sep 17 00:00:00 2001 From: anhductn2001 Date: Mon, 28 Aug 2023 16:54:19 +0700 Subject: [PATCH 2/7] linting --- app/app.go | 1 + app/upgrades/v5/constants.go | 1 + app/upgrades/v5/upgrade.go | 1 + x/mint/simulation/genesis_test.go | 1 + x/ratelimit/keeper/rate_limit.go | 2 +- x/ratelimit/types/quota.go | 2 +- x/tx-boundary/ante/antetest/ante_test.go | 6 +-- .../ante/antetest/ante_test_setup.go | 7 +-- x/tx-boundary/ante/decorate.go | 1 + x/tx-boundary/client/cli/query.go | 1 + x/tx-boundary/client/cli/tx.go | 3 +- x/tx-boundary/keeper/grpc_query.go | 3 +- x/tx-boundary/keeper/keeper.go | 48 +++++++++---------- x/tx-boundary/keeper/msg_server.go | 2 +- x/tx-boundary/module.go | 1 + x/tx-boundary/types/codec.go | 4 +- 16 files changed, 47 insertions(+), 37 deletions(-) diff --git a/app/app.go b/app/app.go index f8b223275..cd10cdfbf 100644 --- a/app/app.go +++ b/app/app.go @@ -708,6 +708,7 @@ func (app *CentauriApp) setupUpgradeStoreLoaders() { } for _, upgrade := range Upgrades { + upgrade := upgrade if upgradeInfo.Name == upgrade.UpgradeName { app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &upgrade.StoreUpgrades)) } diff --git a/app/upgrades/v5/constants.go b/app/upgrades/v5/constants.go index 1bc1c269e..a9ccd019b 100644 --- a/app/upgrades/v5/constants.go +++ b/app/upgrades/v5/constants.go @@ -2,6 +2,7 @@ package v5 import ( store "github.com/cosmos/cosmos-sdk/store/types" + "github.com/notional-labs/centauri/v4/app/upgrades" ) diff --git a/app/upgrades/v5/upgrade.go b/app/upgrades/v5/upgrade.go index 9bcbed994..16f06e794 100644 --- a/app/upgrades/v5/upgrade.go +++ b/app/upgrades/v5/upgrade.go @@ -4,6 +4,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + "github.com/notional-labs/centauri/v4/app/keepers" "github.com/notional-labs/centauri/v4/app/upgrades" ) diff --git a/x/mint/simulation/genesis_test.go b/x/mint/simulation/genesis_test.go index d02138e61..d71a57f34 100644 --- a/x/mint/simulation/genesis_test.go +++ b/x/mint/simulation/genesis_test.go @@ -79,6 +79,7 @@ func TestRandomizedGenState1(t *testing.T) { } for _, tt := range tests { + tt := tt require.Panicsf(t, func() { simulation.RandomizedGenState(&tt.simState) }, tt.panicMsg) } } diff --git a/x/ratelimit/keeper/rate_limit.go b/x/ratelimit/keeper/rate_limit.go index 9e1f6813e..79d2983a7 100644 --- a/x/ratelimit/keeper/rate_limit.go +++ b/x/ratelimit/keeper/rate_limit.go @@ -42,7 +42,7 @@ func EmitTransferDeniedEvent(ctx sdk.Context, reason, denom, channelID string, d } // Adds an amount to the flow in either the SEND or RECV direction -func (k Keeper) UpdateFlow(ctx sdk.Context, rateLimit types.RateLimit, direction types.PacketDirection, amount math.Int) error { +func (k Keeper) UpdateFlow(_ sdk.Context, rateLimit types.RateLimit, direction types.PacketDirection, amount math.Int) error { switch direction { case types.PACKET_SEND: return rateLimit.Flow.AddOutflow(amount, *rateLimit.Quota, rateLimit.MinRateLimitAmount) diff --git a/x/ratelimit/types/quota.go b/x/ratelimit/types/quota.go index 092063b73..f77703e9c 100644 --- a/x/ratelimit/types/quota.go +++ b/x/ratelimit/types/quota.go @@ -5,7 +5,7 @@ import ( ) // CheckExceedsQuota checks if new in/out flow is going to reach the max in/out or not -func (q *Quota) CheckExceedsQuota(direction PacketDirection, amount math.Int, totalValue math.Int, minRateLimitAmount math.Int) bool { +func (q *Quota) CheckExceedsQuota(direction PacketDirection, amount, totalValue, minRateLimitAmount math.Int) bool { // If there's no channel value (this should be almost impossible), it means there is no // supply of the asset, so we shoudn't prevent inflows/outflows if totalValue.IsZero() { diff --git a/x/tx-boundary/ante/antetest/ante_test.go b/x/tx-boundary/ante/antetest/ante_test.go index 86f22435c..fd95f5f8e 100644 --- a/x/tx-boundary/ante/antetest/ante_test.go +++ b/x/tx-boundary/ante/antetest/ante_test.go @@ -9,10 +9,11 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/authz" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - txboundaryAnte "github.com/notional-labs/centauri/v4/x/tx-boundary/ante" - "github.com/notional-labs/centauri/v4/x/tx-boundary/types" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" + + txboundaryAnte "github.com/notional-labs/centauri/v4/x/tx-boundary/ante" + "github.com/notional-labs/centauri/v4/x/tx-boundary/types" ) func TestAnteTestSuite(t *testing.T) { @@ -117,5 +118,4 @@ func (s *AnteTestSuite) TestStakingAnte() { s.Require().Error(err) } } - } diff --git a/x/tx-boundary/ante/antetest/ante_test_setup.go b/x/tx-boundary/ante/antetest/ante_test_setup.go index 33ef2fb6c..0e6386c64 100644 --- a/x/tx-boundary/ante/antetest/ante_test_setup.go +++ b/x/tx-boundary/ante/antetest/ante_test_setup.go @@ -17,10 +17,11 @@ import ( xauthsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/cosmos/ibc-go/v7/testing/mock" - "github.com/notional-labs/centauri/v4/app" - "github.com/notional-labs/centauri/v4/app/helpers" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" + + "github.com/notional-labs/centauri/v4/app" + "github.com/notional-labs/centauri/v4/app/helpers" ) var BaseBalance = sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10000000000))) @@ -78,7 +79,7 @@ func (suite *AnteTestSuite) SetupTest() { suite.clientCtx = client.Context{}.WithTxConfig(encodingConfig.TxConfig) } -func (s *AnteTestSuite) CreateTestTx(privs []cryptotypes.PrivKey, accNums []uint64, accSeqs []uint64, chainID string) (xauthsigning.Tx, error) { +func (s *AnteTestSuite) CreateTestTx(privs []cryptotypes.PrivKey, accNums, accSeqs []uint64, chainID string) (xauthsigning.Tx, error) { var sigsV2 []signing.SignatureV2 for i, priv := range privs { sigV2 := signing.SignatureV2{ diff --git a/x/tx-boundary/ante/decorate.go b/x/tx-boundary/ante/decorate.go index 8bfec5a8f..a04ca57d2 100644 --- a/x/tx-boundary/ante/decorate.go +++ b/x/tx-boundary/ante/decorate.go @@ -9,6 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/authz" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + txBoundaryKeeper "github.com/notional-labs/centauri/v4/x/tx-boundary/keeper" ) diff --git a/x/tx-boundary/client/cli/query.go b/x/tx-boundary/client/cli/query.go index 984b9fb9f..dfec7679a 100644 --- a/x/tx-boundary/client/cli/query.go +++ b/x/tx-boundary/client/cli/query.go @@ -7,6 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/notional-labs/centauri/v4/x/tx-boundary/types" ) diff --git a/x/tx-boundary/client/cli/tx.go b/x/tx-boundary/client/cli/tx.go index e0899b12e..e64432d19 100644 --- a/x/tx-boundary/client/cli/tx.go +++ b/x/tx-boundary/client/cli/tx.go @@ -6,8 +6,9 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" - "github.com/notional-labs/centauri/v4/x/tx-boundary/types" "github.com/spf13/cobra" + + "github.com/notional-labs/centauri/v4/x/tx-boundary/types" ) // GetTxCmd returns the tx commands for tx-boundary diff --git a/x/tx-boundary/keeper/grpc_query.go b/x/tx-boundary/keeper/grpc_query.go index 772ae2f5c..0349e175e 100644 --- a/x/tx-boundary/keeper/grpc_query.go +++ b/x/tx-boundary/keeper/grpc_query.go @@ -4,13 +4,14 @@ import ( "context" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/notional-labs/centauri/v4/x/tx-boundary/types" ) var _ types.QueryServer = Keeper{} // DelegateBoundary returns delegate boundary of the tx-boundary module. -func (k Keeper) DelegateBoundary(c context.Context, req *types.QueryDelegateBoundaryRequest) (*types.QueryDelegateBoundaryResponse, error) { +func (k Keeper) DelegateBoundary(c context.Context, _ *types.QueryDelegateBoundaryRequest) (*types.QueryDelegateBoundaryResponse, error) { ctx := sdk.UnwrapSDKContext(c) boundary := k.GetDelegateBoundary(ctx) diff --git a/x/tx-boundary/keeper/keeper.go b/x/tx-boundary/keeper/keeper.go index 135ef46a9..a5fb7b225 100644 --- a/x/tx-boundary/keeper/keeper.go +++ b/x/tx-boundary/keeper/keeper.go @@ -88,9 +88,9 @@ func (k Keeper) GetRedelegateBoundary(ctx sdk.Context) (boundary types.Boundary) } // SetDelegateCount set the number of delegate tx for a given address -func (k Keeper) SetLimitPerAddr(ctx sdk.Context, addr sdk.AccAddress, limit_per_addr types.LimitPerAddr) { +func (k Keeper) SetLimitPerAddr(ctx sdk.Context, addr sdk.AccAddress, limitPerAddr types.LimitPerAddr) { store := ctx.KVStore(k.storeKey) - bz := k.cdc.MustMarshal(&limit_per_addr) + bz := k.cdc.MustMarshal(&limitPerAddr) store.Set(addr, bz) } @@ -105,10 +105,10 @@ func (k Keeper) IncrementDelegateCount(ctx sdk.Context, addr sdk.AccAddress) { return } bz := store.Get(addr) - var limit_per_addr types.LimitPerAddr - k.cdc.MustUnmarshal(bz, &limit_per_addr) - limit_per_addr.DelegateCount += 1 - k.SetLimitPerAddr(ctx, addr, limit_per_addr) + var limitPerAddr types.LimitPerAddr + k.cdc.MustUnmarshal(bz, &limitPerAddr) + limitPerAddr.DelegateCount += 1 + k.SetLimitPerAddr(ctx, addr, limitPerAddr) return } @@ -123,15 +123,15 @@ func (k Keeper) IncrementRedelegateCount(ctx sdk.Context, addr sdk.AccAddress) { return } bz := store.Get(addr) - var limit_per_addr types.LimitPerAddr - k.cdc.MustUnmarshal(bz, &limit_per_addr) - limit_per_addr.ReledegateCount += 1 - k.SetLimitPerAddr(ctx, addr, limit_per_addr) + var limitPerAddr types.LimitPerAddr + k.cdc.MustUnmarshal(bz, &limitPerAddr) + limitPerAddr.ReledegateCount += 1 + k.SetLimitPerAddr(ctx, addr, limitPerAddr) return } // GetDelegateCount get the number of delegate tx for a given address -func (k Keeper) GetLimitPerAddr(ctx sdk.Context, addr sdk.AccAddress) (limit_per_addr types.LimitPerAddr) { +func (k Keeper) GetLimitPerAddr(ctx sdk.Context, addr sdk.AccAddress) (limitPerAddr types.LimitPerAddr) { store := ctx.KVStore(k.storeKey) if store.Has(addr) == false { return types.LimitPerAddr{ @@ -141,20 +141,20 @@ func (k Keeper) GetLimitPerAddr(ctx sdk.Context, addr sdk.AccAddress) (limit_per } } bz := store.Get(addr) - k.cdc.MustUnmarshal(bz, &limit_per_addr) + k.cdc.MustUnmarshal(bz, &limitPerAddr) return } func (k Keeper) UpdateLimitPerAddr(ctx sdk.Context, addr sdk.AccAddress) { - limit_per_addr := k.GetLimitPerAddr(ctx, addr) - if limit_per_addr.LatestUpdateBlock == 0 { + limitPerAddr := k.GetLimitPerAddr(ctx, addr) + if limitPerAddr.LatestUpdateBlock == 0 { return } boundary := k.GetDelegateBoundary(ctx) - if limit_per_addr.LatestUpdateBlock+int64(boundary.BlocksPerGeneration) >= ctx.BlockHeight() { - // Calculate the generated tx number from the duration between latest update block and curent block height + if limitPerAddr.LatestUpdateBlock+int64(boundary.BlocksPerGeneration) >= ctx.BlockHeight() { + // Calculate the generated tx number from the duration between latest update block and current block height var generatedTx uint64 - duration := uint64(limit_per_addr.LatestUpdateBlock) + boundary.BlocksPerGeneration - uint64(ctx.BlockHeight()) + duration := uint64(limitPerAddr.LatestUpdateBlock) + boundary.BlocksPerGeneration - uint64(ctx.BlockHeight()) if duration/boundary.BlocksPerGeneration > 5 { generatedTx = 5 } else { @@ -162,19 +162,19 @@ func (k Keeper) UpdateLimitPerAddr(ctx sdk.Context, addr sdk.AccAddress) { } // Update the delegate tx limit - if uint64(generatedTx) > limit_per_addr.DelegateCount { - limit_per_addr.DelegateCount = 0 + if generatedTx > limitPerAddr.DelegateCount { + limitPerAddr.DelegateCount = 0 } else { - limit_per_addr.DelegateCount -= uint64(generatedTx) + limitPerAddr.DelegateCount -= generatedTx } // Update the redelegate tx limit - if uint64(generatedTx) > limit_per_addr.ReledegateCount { - limit_per_addr.ReledegateCount = 0 + if uint64(generatedTx) > limitPerAddr.ReledegateCount { + limitPerAddr.ReledegateCount = 0 } else { - limit_per_addr.ReledegateCount -= uint64(generatedTx) + limitPerAddr.ReledegateCount -= uint64(generatedTx) } // Update LatestUpdateBlock - limit_per_addr.LatestUpdateBlock = ctx.BlockHeight() + limitPerAddr.LatestUpdateBlock = ctx.BlockHeight() return } return diff --git a/x/tx-boundary/keeper/msg_server.go b/x/tx-boundary/keeper/msg_server.go index d810a5e68..b55569d4a 100644 --- a/x/tx-boundary/keeper/msg_server.go +++ b/x/tx-boundary/keeper/msg_server.go @@ -1 +1 @@ -package keeper \ No newline at end of file +package keeper diff --git a/x/tx-boundary/module.go b/x/tx-boundary/module.go index dd980fe34..26d8b97fd 100644 --- a/x/tx-boundary/module.go +++ b/x/tx-boundary/module.go @@ -15,6 +15,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/notional-labs/centauri/v4/x/tx-boundary/client/cli" "github.com/notional-labs/centauri/v4/x/tx-boundary/keeper" "github.com/notional-labs/centauri/v4/x/tx-boundary/types" diff --git a/x/tx-boundary/types/codec.go b/x/tx-boundary/types/codec.go index cc858e223..b2822d85b 100644 --- a/x/tx-boundary/types/codec.go +++ b/x/tx-boundary/types/codec.go @@ -23,9 +23,9 @@ func init() { } // RegisterLegacyAminoCodec registers concrete types on the LegacyAmino codec -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func RegisterLegacyAminoCodec(_ *codec.LegacyAmino) { } // RegisterInterfaces registers the interfaces types with the interface registry. -func RegisterInterfaces(registry types.InterfaceRegistry) { +func RegisterInterfaces(_ types.InterfaceRegistry) { } From 47f9a768f4c9768f6c697d88056d93d2717deb3f Mon Sep 17 00:00:00 2001 From: anhductn2001 Date: Mon, 28 Aug 2023 17:09:42 +0700 Subject: [PATCH 3/7] linting --- app/upgrades/v5/upgrade.go | 2 +- custom/bank/bank_test.go | 3 +-- .../ante/antetest/ante_test_setup.go | 2 +- x/tx-boundary/client/cli/tx.go | 20 +++++++++---------- x/tx-boundary/keeper/keeper.go | 17 +++++++--------- x/tx-boundary/module.go | 4 ++-- 6 files changed, 22 insertions(+), 26 deletions(-) diff --git a/app/upgrades/v5/upgrade.go b/app/upgrades/v5/upgrade.go index 16f06e794..3ffbaeffa 100644 --- a/app/upgrades/v5/upgrade.go +++ b/app/upgrades/v5/upgrade.go @@ -12,7 +12,7 @@ import ( func CreateUpgradeHandler( mm *module.Manager, configurator module.Configurator, - bpm upgrades.BaseAppParamManager, + _ upgrades.BaseAppParamManager, keepers *keepers.AppKeepers, ) upgradetypes.UpgradeHandler { return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { diff --git a/custom/bank/bank_test.go b/custom/bank/bank_test.go index ed208413a..6492a7c07 100644 --- a/custom/bank/bank_test.go +++ b/custom/bank/bank_test.go @@ -6,7 +6,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" - transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" "github.com/stretchr/testify/suite" @@ -59,7 +58,7 @@ func (suite *CustomBankTestSuite) TestTotalSupply() { var ( expChainBBalanceDiff sdk.Coin path = NewTransferPath(suite.chainA, suite.chainB) - escrowAddr = transfertypes.GetEscrowAddress(transfertypes.PortID, "channel-0") + escrowAddr = ibctransfertypes.GetEscrowAddress(ibctransfertypes.PortID, "channel-0") ) testCases := []struct { diff --git a/x/tx-boundary/ante/antetest/ante_test_setup.go b/x/tx-boundary/ante/antetest/ante_test_setup.go index 0e6386c64..a40476568 100644 --- a/x/tx-boundary/ante/antetest/ante_test_setup.go +++ b/x/tx-boundary/ante/antetest/ante_test_setup.go @@ -42,7 +42,7 @@ type AnteTestSuite struct { func (suite *AnteTestSuite) SetupTest() { suite.app, suite.delegator, suite.validators = helpers.SetupCentauriAppWithValSetWithGenAccout(suite.T()) suite.ctx = suite.app.BaseApp.NewContext(false, tmproto.Header{Height: 1, ChainID: "centauri-1", Time: time.Now().UTC()}) - app.FundAccount(suite.app.BankKeeper, suite.ctx, sdk.AccAddress(suite.delegator), BaseBalance) + app.FundAccount(suite.app.BankKeeper, suite.ctx, suite.delegator, BaseBalance) encodingConfig := app.MakeEncodingConfig() encodingConfig.Amino.RegisterConcrete(&testdata.TestMsg{}, "testdata.TestMsg", nil) diff --git a/x/tx-boundary/client/cli/tx.go b/x/tx-boundary/client/cli/tx.go index e64432d19..daff1eea2 100644 --- a/x/tx-boundary/client/cli/tx.go +++ b/x/tx-boundary/client/cli/tx.go @@ -30,7 +30,7 @@ func GetTxCmd() *cobra.Command { func GetCmdUpdateDelegateBoundary() *cobra.Command { cmd := &cobra.Command{ - Use: "update-delegate [tx_limit] [block_per_generation]", + Use: "update-delegate [txLimit] [blockPerGeneration]", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) @@ -38,20 +38,20 @@ func GetCmdUpdateDelegateBoundary() *cobra.Command { return err } - tx_limit, err := strconv.ParseUint(args[0], 10, 64) + txLimit, err := strconv.ParseUint(args[0], 10, 64) if err != nil { return err } - block_per_generation, err := strconv.ParseUint(args[1], 10, 64) + blockPerGeneration, err := strconv.ParseUint(args[1], 10, 64) if err != nil { return err } msg := types.NewMsgUpdateDelegateBoundary( types.Boundary{ - TxLimit: tx_limit, - BlocksPerGeneration: block_per_generation, + TxLimit: txLimit, + BlocksPerGeneration: blockPerGeneration, }, clientCtx.GetFromAddress().String(), ) @@ -65,7 +65,7 @@ func GetCmdUpdateDelegateBoundary() *cobra.Command { func GetCmdUpdateRedelegateBoundary() *cobra.Command { cmd := &cobra.Command{ - Use: "update-redelegate [tx_limit] [block_per_generation]", + Use: "update-redelegate [txLimit] [blockPerGeneration]", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) @@ -73,20 +73,20 @@ func GetCmdUpdateRedelegateBoundary() *cobra.Command { return err } - tx_limit, err := strconv.ParseUint(args[0], 10, 64) + txLimit, err := strconv.ParseUint(args[0], 10, 64) if err != nil { return err } - block_per_generation, err := strconv.ParseUint(args[1], 10, 64) + blockPerGeneration, err := strconv.ParseUint(args[1], 10, 64) if err != nil { return err } msg := types.NewMsgUpdateRedelegateBoundary( types.Boundary{ - TxLimit: tx_limit, - BlocksPerGeneration: block_per_generation, + TxLimit: txLimit, + BlocksPerGeneration: blockPerGeneration, }, clientCtx.GetFromAddress().String(), ) diff --git a/x/tx-boundary/keeper/keeper.go b/x/tx-boundary/keeper/keeper.go index a5fb7b225..ea1518314 100644 --- a/x/tx-boundary/keeper/keeper.go +++ b/x/tx-boundary/keeper/keeper.go @@ -96,7 +96,7 @@ func (k Keeper) SetLimitPerAddr(ctx sdk.Context, addr sdk.AccAddress, limitPerAd func (k Keeper) IncrementDelegateCount(ctx sdk.Context, addr sdk.AccAddress) { store := ctx.KVStore(k.storeKey) - if store.Has(addr) == false { + if !store.Has(addr) { k.SetLimitPerAddr(ctx, addr, types.LimitPerAddr{ DelegateCount: 1, ReledegateCount: 0, @@ -107,14 +107,13 @@ func (k Keeper) IncrementDelegateCount(ctx sdk.Context, addr sdk.AccAddress) { bz := store.Get(addr) var limitPerAddr types.LimitPerAddr k.cdc.MustUnmarshal(bz, &limitPerAddr) - limitPerAddr.DelegateCount += 1 + limitPerAddr.DelegateCount++ k.SetLimitPerAddr(ctx, addr, limitPerAddr) - return } func (k Keeper) IncrementRedelegateCount(ctx sdk.Context, addr sdk.AccAddress) { store := ctx.KVStore(k.storeKey) - if store.Has(addr) == false { + if !store.Has(addr) { k.SetLimitPerAddr(ctx, addr, types.LimitPerAddr{ DelegateCount: 0, ReledegateCount: 1, @@ -125,15 +124,14 @@ func (k Keeper) IncrementRedelegateCount(ctx sdk.Context, addr sdk.AccAddress) { bz := store.Get(addr) var limitPerAddr types.LimitPerAddr k.cdc.MustUnmarshal(bz, &limitPerAddr) - limitPerAddr.ReledegateCount += 1 + limitPerAddr.ReledegateCount++ k.SetLimitPerAddr(ctx, addr, limitPerAddr) - return } // GetDelegateCount get the number of delegate tx for a given address func (k Keeper) GetLimitPerAddr(ctx sdk.Context, addr sdk.AccAddress) (limitPerAddr types.LimitPerAddr) { store := ctx.KVStore(k.storeKey) - if store.Has(addr) == false { + if !store.Has(addr) { return types.LimitPerAddr{ DelegateCount: 0, ReledegateCount: 0, @@ -168,14 +166,13 @@ func (k Keeper) UpdateLimitPerAddr(ctx sdk.Context, addr sdk.AccAddress) { limitPerAddr.DelegateCount -= generatedTx } // Update the redelegate tx limit - if uint64(generatedTx) > limitPerAddr.ReledegateCount { + if generatedTx > limitPerAddr.ReledegateCount { limitPerAddr.ReledegateCount = 0 } else { - limitPerAddr.ReledegateCount -= uint64(generatedTx) + limitPerAddr.ReledegateCount -= generatedTx } // Update LatestUpdateBlock limitPerAddr.LatestUpdateBlock = ctx.BlockHeight() return } - return } diff --git a/x/tx-boundary/module.go b/x/tx-boundary/module.go index 26d8b97fd..d2673731d 100644 --- a/x/tx-boundary/module.go +++ b/x/tx-boundary/module.go @@ -111,7 +111,7 @@ func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} // RegisterServices registers a gRPC query service to respond to the // module-specific gRPC queries. -func (am AppModule) RegisterServices(cfg module.Configurator) { +func (am AppModule) RegisterServices(_ module.Configurator) { // types.RegisterQueryServer(cfg.QueryServer(), am.keeper) // types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) } @@ -137,7 +137,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw func (AppModule) ConsensusVersion() uint64 { return 1 } // BeginBlock returns the begin blocker for the tx-boundary module. -func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) {} +func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} // ProposalContents doesn't return any content functions for governance proposals. func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalMsg { From 1698b0466832c985033b2380a015d5329ea2b95a Mon Sep 17 00:00:00 2001 From: anhductn2001 Date: Mon, 28 Aug 2023 17:14:23 +0700 Subject: [PATCH 4/7] linting --- .golangci.yml | 1 - app/upgrades/v5/upgrade.go | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 4182c4e9e..c0844c760 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -21,7 +21,6 @@ linters: - nakedret - nolintlint - staticcheck - - revive - stylecheck - thelper - typecheck diff --git a/app/upgrades/v5/upgrade.go b/app/upgrades/v5/upgrade.go index 3ffbaeffa..5cf028050 100644 --- a/app/upgrades/v5/upgrade.go +++ b/app/upgrades/v5/upgrade.go @@ -13,7 +13,7 @@ func CreateUpgradeHandler( mm *module.Manager, configurator module.Configurator, _ upgrades.BaseAppParamManager, - keepers *keepers.AppKeepers, + _ *keepers.AppKeepers, ) upgradetypes.UpgradeHandler { return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { return mm.RunMigrations(ctx, configurator, vm) From c892081e879f16ea82fe0659b78b46623320b02d Mon Sep 17 00:00:00 2001 From: anhductn2001 Date: Tue, 29 Aug 2023 12:42:12 +0700 Subject: [PATCH 5/7] v5 --- x/tx-boundary/ante/antetest/ante_test_setup.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/tx-boundary/ante/antetest/ante_test_setup.go b/x/tx-boundary/ante/antetest/ante_test_setup.go index cf8e2df25..3d2fda475 100644 --- a/x/tx-boundary/ante/antetest/ante_test_setup.go +++ b/x/tx-boundary/ante/antetest/ante_test_setup.go @@ -22,8 +22,8 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - "github.com/notional-labs/centauri/v4/app" - "github.com/notional-labs/centauri/v4/app/helpers" + "github.com/notional-labs/centauri/v5/app" + "github.com/notional-labs/centauri/v5/app/helpers" ) var BaseBalance = sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10000000000))) From 1ab367469681ea338731e38415b8977eb39c44e5 Mon Sep 17 00:00:00 2001 From: anhductn2001 Date: Tue, 29 Aug 2023 12:50:50 +0700 Subject: [PATCH 6/7] linting --- app/upgrades/v5/upgrade.go | 2 +- x/tx-boundary/ante/antetest/ante_test_setup.go | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/app/upgrades/v5/upgrade.go b/app/upgrades/v5/upgrade.go index bdb58428a..962254d03 100644 --- a/app/upgrades/v5/upgrade.go +++ b/app/upgrades/v5/upgrade.go @@ -22,7 +22,7 @@ func CreateUpgradeHandler( mm *module.Manager, configurator module.Configurator, _ upgrades.BaseAppParamManager, - _ *keepers.AppKeepers, + keepers *keepers.AppKeepers, ) upgradetypes.UpgradeHandler { return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { // add min amount for rate limit diff --git a/x/tx-boundary/ante/antetest/ante_test_setup.go b/x/tx-boundary/ante/antetest/ante_test_setup.go index 3d2fda475..96da98aba 100644 --- a/x/tx-boundary/ante/antetest/ante_test_setup.go +++ b/x/tx-boundary/ante/antetest/ante_test_setup.go @@ -21,9 +21,6 @@ import ( "github.com/notional-labs/centauri/v5/app/helpers" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - - "github.com/notional-labs/centauri/v5/app" - "github.com/notional-labs/centauri/v5/app/helpers" ) var BaseBalance = sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10000000000))) From 5511fec5c2bf8655b9c903befe0e8e94c095ddb6 Mon Sep 17 00:00:00 2001 From: anhductn2001 Date: Tue, 29 Aug 2023 13:09:04 +0700 Subject: [PATCH 7/7] no need panic --- app/upgrades/v5/upgrade.go | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/app/upgrades/v5/upgrade.go b/app/upgrades/v5/upgrade.go index 962254d03..93da70da2 100644 --- a/app/upgrades/v5/upgrade.go +++ b/app/upgrades/v5/upgrade.go @@ -31,9 +31,6 @@ func CreateUpgradeHandler( uatomRateLimit, found := rlKeeper.GetRateLimit(ctx, uatom, "channel-2") if !found { channelValue := rlKeeper.GetChannelValue(ctx, uatom) - if channelValue.IsZero() { - panic("Zero ATOM channel value") - } // Create and store the rate limit object path := types.Path{ Denom: uatom, @@ -64,9 +61,6 @@ func CreateUpgradeHandler( dotRateLimit, found := rlKeeper.GetRateLimit(ctx, dot, "channel-2") if !found { channelValue := rlKeeper.GetChannelValue(ctx, dot) - if channelValue.IsZero() { - panic("Zero DOT channel value") - } // Create and store the rate limit object path := types.Path{ Denom: dot, @@ -97,9 +91,6 @@ func CreateUpgradeHandler( ksmRateLimit, found := rlKeeper.GetRateLimit(ctx, ksm, "channel-2") if !found { channelValue := rlKeeper.GetChannelValue(ctx, ksm) - if channelValue.IsZero() { - panic("Zero KSM channel value") - } // Create and store the rate limit object path := types.Path{ Denom: ksm, @@ -130,9 +121,6 @@ func CreateUpgradeHandler( usdtRateLimit, found := rlKeeper.GetRateLimit(ctx, usdt, "channel-2") if !found { channelValue := rlKeeper.GetChannelValue(ctx, usdt) - if channelValue.IsZero() { - panic("Zero USDT channel value") - } // Create and store the rate limit object path := types.Path{ Denom: usdt,