Skip to content

Commit

Permalink
gofumpt
Browse files Browse the repository at this point in the history
  • Loading branch information
puneet2019 committed Jan 12, 2024
1 parent d7b62b9 commit 304f6e4
Show file tree
Hide file tree
Showing 69 changed files with 279 additions and 292 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: "v1.52.2"
version: "v1.55.0"
args: --timeout=5m
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,12 @@ rm-testcache:
###############################################################################
### Linting ###
###############################################################################
golangci_version=v1.55.0

lint-install:
@echo "--> Installing golangci-lint $(golangci_version)"
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version)


lint:
golangci-lint run
Expand Down
2 changes: 1 addition & 1 deletion ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func NewAnteHandler(opts HandlerOptions) (sdk.AnteHandler, error) {
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for ante builder")
}

var sigGasConsumer = opts.SigGasConsumer
sigGasConsumer := opts.SigGasConsumer
if sigGasConsumer == nil {
sigGasConsumer = ante.DefaultSigVerificationGasConsumer
}
Expand Down
16 changes: 8 additions & 8 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,8 @@ func NewpStakeApp(
app.BankKeeper,
scopedTransferKeeper,
)
//transferModule := transfer.NewAppModule(app.TransferKeeper)
//transferIBCModule := transfer.NewIBCModule(app.TransferKeeper)
// transferModule := transfer.NewAppModule(app.TransferKeeper)
// transferIBCModule := transfer.NewIBCModule(app.TransferKeeper)

app.ICAControllerKeeper = icacontrollerkeeper.NewKeeper(
appCodec, keys[icacontrollertypes.StoreKey],
Expand All @@ -487,7 +487,7 @@ func NewpStakeApp(
app.MsgServiceRouter(),
)

//icaModule := ica.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper)
// icaModule := ica.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper)

app.InterchainQueryKeeper = interchainquerykeeper.NewKeeper(appCodec, keys[interchainquerytypes.StoreKey], app.IBCKeeper)
interchainQueryModule := interchainquery.NewAppModule(appCodec, app.InterchainQueryKeeper)
Expand Down Expand Up @@ -623,7 +623,7 @@ func NewpStakeApp(
transfer.NewAppModule(app.TransferKeeper),
ibcfee.NewAppModule(app.IBCFeeKeeper),
ica.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper),
//ibchooker.NewAppModule(),
// ibchooker.NewAppModule(),
interchainQueryModule,
liquidstakeibc.NewAppModule(app.LiquidStakeIBCKeeper),
liquidstake.NewAppModule(app.LiquidStakeKeeper),
Expand Down Expand Up @@ -659,7 +659,7 @@ func NewpStakeApp(
feegrant.ModuleName,
paramstypes.ModuleName,
vestingtypes.ModuleName,
ibchookertypes.ModuleName, //Noop
ibchookertypes.ModuleName, // Noop
interchainquerytypes.ModuleName,
liquidstakeibctypes.ModuleName,
liquidstaketypes.ModuleName,
Expand Down Expand Up @@ -688,7 +688,7 @@ func NewpStakeApp(
paramstypes.ModuleName,
upgradetypes.ModuleName,
vestingtypes.ModuleName,
ibchookertypes.ModuleName, //Noop
ibchookertypes.ModuleName, // Noop
interchainquerytypes.ModuleName,
liquidstakeibctypes.ModuleName,
liquidstaketypes.ModuleName,
Expand Down Expand Up @@ -724,7 +724,7 @@ func NewpStakeApp(
paramstypes.ModuleName,
upgradetypes.ModuleName,
vestingtypes.ModuleName,
ibchookertypes.ModuleName, //Noop
ibchookertypes.ModuleName, // Noop
interchainquerytypes.ModuleName,
liquidstakeibctypes.ModuleName,
liquidstaketypes.ModuleName,
Expand Down Expand Up @@ -849,6 +849,7 @@ func (app *PstakeApp) ModuleAccountAddrs() map[string]bool {

return modAccAddrs
}

func (app *PstakeApp) SendCoinBlockedAddrs() map[string]bool {
modAccAddrs := make(map[string]bool)
for acc := range maccPerms {
Expand Down Expand Up @@ -1018,7 +1019,6 @@ func (app *PstakeApp) RegisterUpgradeHandler() {
app.UpgradeKeeper.SetUpgradeHandler(
UpgradeName,
func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {

// stuck unbonding epoch numbers
RemovableUnbondings := map[string]map[int64]any{"cosmoshub-4": {312: nil}, "osmosis-1": {429: nil, 432: nil}}

Expand Down
2 changes: 1 addition & 1 deletion app/helpers/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func NewConfig(dbm *dbm.MemDB) network.Config {

// NewAppConstructor returns a new network AppConstructor.
//
//nolint:interfacer
//nolint:interfacer // only used for tests
func NewAppConstructor(encodingCfg appparams.EncodingConfig, db *dbm.MemDB) network.AppConstructor {
return func(val network.ValidatorI) types.Application {
return app.NewpStakeApp(
Expand Down
2 changes: 1 addition & 1 deletion cmd/pstaked/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func initTendermintConfig() *tmcfg.Config {

return cfg
}

func initAppConfig() (string, interface{}) {
srvCfg := serverconfig.DefaultConfig()
srvCfg.StateSync.SnapshotInterval = 1000
Expand Down Expand Up @@ -245,5 +246,4 @@ func (ac appCreator) appExport(
}

return pStakeApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs, modulesToExport)

}
1 change: 0 additions & 1 deletion cmd/pstaked/cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
)

func TestRootCmdConfig(t *testing.T) {

rootCmd, _ := cmd.NewRootCmd()
rootCmd.SetArgs([]string{
"config", // Test the config cmd
Expand Down
9 changes: 3 additions & 6 deletions cmd/pstaked/cmd/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Example:
return cmd
}

const nodeDirPerm = 0755
const nodeDirPerm = 0o755

// Initialize the testnet
func InitTestnet(
Expand All @@ -126,7 +126,6 @@ func InitTestnet(
algoStr string,
numValidators int,
) error {

if chainID == "" {
chainID = "chain-" + tmrand.NewRand().Str(6)
}
Expand Down Expand Up @@ -288,7 +287,6 @@ func initGenFiles(
genAccounts []authtypes.GenesisAccount, genBalances []banktypes.Balance,
genFiles []string, numValidators int,
) error {

appGenState := mbm.DefaultGenesis(clientCtx.Codec)

// set the accounts in the genesis state
Expand Down Expand Up @@ -337,7 +335,6 @@ func collectGenFiles(
nodeIDs []string, valPubKeys []cryptotypes.PubKey, numValidators int,
outputDir, nodeDirPrefix, nodeDaemonHome string, genBalIterator banktypes.GenesisBalancesIterator,
) error {

var appState json.RawMessage
genTime := tmtime.Now()

Expand Down Expand Up @@ -406,12 +403,12 @@ func writeFile(name string, dir string, contents []byte) error {
writePath := filepath.Clean(dir)
file := filepath.Join(writePath, name)

err := tmos.EnsureDir(writePath, 0755)
err := tmos.EnsureDir(writePath, 0o755)
if err != nil {
return err
}

err = tmos.WriteFile(file, contents, 0644)
err = tmos.WriteFile(file, contents, 0o644)
if err != nil {
return err
}
Expand Down
17 changes: 7 additions & 10 deletions x/liquidstake/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ import (
"github.com/persistenceOne/pstake-native/v2/x/liquidstake/types"
)

var (
BlockTime = 10 * time.Second
)
var BlockTime = 10 * time.Second

type KeeperTestSuite struct {
suite.Suite
Expand Down Expand Up @@ -246,7 +244,6 @@ func (s *KeeperTestSuite) RequireNetAmountStateZero() {
s.Require().EqualValues(nas.TotalRemainingRewards, sdk.ZeroDec())
s.Require().EqualValues(nas.TotalUnbondingBalance, sdk.ZeroDec())
s.Require().EqualValues(nas.ProxyAccBalance, sdk.ZeroInt())

}

// advance block time and height for complete redelegations and unbondings
Expand Down Expand Up @@ -396,8 +393,8 @@ func (s *KeeperTestSuite) doubleSign(valOper sdk.ValAddress, consAddr sdk.ConsAd

// make evidence
evidence := &evidencetypes.Equivocation{
//Height: 0,
//Time: time.Unix(0, 0),
// Height: 0,
// Time: time.Unix(0, 0),
Height: s.ctx.BlockHeight(),
Time: s.ctx.BlockTime(),
Power: s.app.StakingKeeper.TokensToConsensusPower(s.ctx, tokens),
Expand All @@ -407,10 +404,10 @@ func (s *KeeperTestSuite) doubleSign(valOper sdk.ValAddress, consAddr sdk.ConsAd
// Double sign
s.app.EvidenceKeeper.HandleEquivocationEvidence(s.ctx, evidence)
// HandleEquivocationEvidence call below functions
//s.app.SlashingKeeper.Slash()
//s.app.SlashingKeeper.Jail(s.ctx, consAddr)
//s.app.SlashingKeeper.JailUntil(s.ctx, consAddr, evidencetypes.DoubleSignJailEndTime)
//s.app.SlashingKeeper.Tombstone(s.ctx, consAddr)
// s.app.SlashingKeeper.Slash()
// s.app.SlashingKeeper.Jail(s.ctx, consAddr)
// s.app.SlashingKeeper.JailUntil(s.ctx, consAddr, evidencetypes.DoubleSignJailEndTime)
// s.app.SlashingKeeper.Tombstone(s.ctx, consAddr)

// should be jailed and tombstoned
s.Require().True(s.app.StakingKeeper.Validator(s.ctx, liquidValidator.GetOperator()).IsJailed())
Expand Down
4 changes: 2 additions & 2 deletions x/liquidstake/keeper/liquidstake.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ func (k Keeper) GetNetAmountState(ctx sdk.Context) (nas types.NetAmountState) {

// LiquidStake mints stkXPRT worth of staking coin value according to NetAmount and performs LiquidDelegate.
func (k Keeper) LiquidStake(
ctx sdk.Context, proxyAcc, liquidStaker sdk.AccAddress, stakingCoin sdk.Coin) (newShares math.LegacyDec, stkXPRTMintAmount math.Int, err error) {
ctx sdk.Context, proxyAcc, liquidStaker sdk.AccAddress, stakingCoin sdk.Coin,
) (newShares math.LegacyDec, stkXPRTMintAmount math.Int, err error) {
params := k.GetParams(ctx)

// check minimum liquid stake amount
Expand Down Expand Up @@ -343,7 +344,6 @@ func (k Keeper) LiquidDelegate(ctx sdk.Context, proxyAcc sdk.AccAddress, activeV
func (k Keeper) LiquidUnstake(
ctx sdk.Context, proxyAcc, liquidStaker sdk.AccAddress, unstakingStkXPRT sdk.Coin,
) (time.Time, math.Int, []stakingtypes.UnbondingDelegation, math.Int, error) {

// check bond denomination
params := k.GetParams(ctx)
liquidBondDenom := k.LiquidBondDenom(ctx)
Expand Down
5 changes: 3 additions & 2 deletions x/liquidstake/keeper/rebalancing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (s *KeeperTestSuite) TestRebalancingCase1() {
s.Require().EqualValues(stakingAmt, totalLiquidTokens)
s.printRedelegationsLiquidTokens()

//reds := s.app.StakingKeeper.GetRedelegations(s.ctx, types.LiquidStakeProxyAcc, 20)
// reds := s.app.StakingKeeper.GetRedelegations(s.ctx, types.LiquidStakeProxyAcc, 20)
s.Require().Len(reds, 3)

testhelpers.PP("before complete")
Expand Down Expand Up @@ -278,7 +278,8 @@ func (s *KeeperTestSuite) TestRebalancingConsecutiveCase() {
_, valOpers, _ := s.CreateValidators([]int64{
1000000, 1000000, 1000000, 1000000, 1000000,
1000000, 1000000, 1000000, 1000000, 1000000,
1000000, 1000000, 1000000, 1000000, 1000000})
1000000, 1000000, 1000000, 1000000, 1000000,
})
s.ctx = s.ctx.WithBlockHeight(100).WithBlockTime(testhelpers.ParseTime("2022-03-01T00:00:00Z"))
params := s.keeper.GetParams(s.ctx)
params.UnstakeFeeRate = sdk.ZeroDec()
Expand Down
3 changes: 1 addition & 2 deletions x/liquidstake/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ var (
)

// AppModuleBasic defines the basic application module used by the liquidstake module.
type AppModuleBasic struct {
}
type AppModuleBasic struct{}

// Name returns the liquidstake module's name.
func (AppModuleBasic) Name() string {
Expand Down
6 changes: 4 additions & 2 deletions x/liquidstake/types/liquidstake.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,10 @@ func ActiveCondition(validator stakingtypes.Validator, whitelisted bool, tombsto
}

// LiquidValidators is a collection of LiquidValidator
type LiquidValidators []LiquidValidator
type ActiveLiquidValidators LiquidValidators
type (
LiquidValidators []LiquidValidator
ActiveLiquidValidators LiquidValidators
)

// MinMaxGap Return the list of LiquidValidator with the maximum gap and minimum gap from the target weight of LiquidValidators, respectively.
func (vs LiquidValidators) MinMaxGap(targetMap, liquidTokenMap map[string]math.Int) (minGapVal LiquidValidator, maxGapVal LiquidValidator, amountNeeded math.Int, lastRedelegation bool) {
Expand Down
38 changes: 18 additions & 20 deletions x/liquidstake/types/liquidstake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,24 @@ import (
"github.com/persistenceOne/pstake-native/v2/x/liquidstake/types"
)

var (
whitelistedValidators = []types.WhitelistedValidator{
{
ValidatorAddress: "cosmosvaloper10e4vsut6suau8tk9m6dnrm0slgd6npe3jx5xpv",
TargetWeight: math.NewInt(10),
},
{
ValidatorAddress: "cosmosvaloper18hfzxheyknesfgcrttr5dg50ffnfphtwtar9fz",
TargetWeight: math.NewInt(1),
},
{
ValidatorAddress: "cosmosvaloper18hfzxheyknesfgcrttr5dg50ffnfphtwtar9fz",
TargetWeight: math.NewInt(-1),
},
{
ValidatorAddress: "cosmosvaloper1ld6vlyy24906u3aqp5lj54f3nsg2592nm9nj5c",
TargetWeight: math.NewInt(0),
},
}
)
var whitelistedValidators = []types.WhitelistedValidator{
{
ValidatorAddress: "cosmosvaloper10e4vsut6suau8tk9m6dnrm0slgd6npe3jx5xpv",
TargetWeight: math.NewInt(10),
},
{
ValidatorAddress: "cosmosvaloper18hfzxheyknesfgcrttr5dg50ffnfphtwtar9fz",
TargetWeight: math.NewInt(1),
},
{
ValidatorAddress: "cosmosvaloper18hfzxheyknesfgcrttr5dg50ffnfphtwtar9fz",
TargetWeight: math.NewInt(-1),
},
{
ValidatorAddress: "cosmosvaloper1ld6vlyy24906u3aqp5lj54f3nsg2592nm9nj5c",
TargetWeight: math.NewInt(0),
},
}

func TestStkXPRTToNativeTokenWithFee(t *testing.T) {
testCases := []struct {
Expand Down
1 change: 0 additions & 1 deletion x/liquidstake/types/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
)

func TestParams(t *testing.T) {

params := types.DefaultParams()

paramsStr := `{
Expand Down
33 changes: 16 additions & 17 deletions x/liquidstake/types/rebalancing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,20 @@ import (
"github.com/persistenceOne/pstake-native/v2/x/liquidstake/types"
)

var (
liquidValidators = []types.LiquidValidator{
{
OperatorAddress: "persistencevaloper15kdfwczhpmccprekhlzrvkhzw92940l3w37qqj",
},
{
OperatorAddress: "persistencevaloper1x73gyvh74ahs2rt9cqrpjkkk74nczwfpnskv3rczmsf0m6aj5dksqr58m3",
},
{
OperatorAddress: "persistencevaloper10ngyx42lfpylpllm4k3g7fz4gufnt3ptyhm5pn",
},
{
OperatorAddress: "persistencevaloper10fcwju2n8vvffkp8judj3skqpvnphasxjar5yx",
},
}
)
var liquidValidators = []types.LiquidValidator{
{
OperatorAddress: "persistencevaloper15kdfwczhpmccprekhlzrvkhzw92940l3w37qqj",
},
{
OperatorAddress: "persistencevaloper1x73gyvh74ahs2rt9cqrpjkkk74nczwfpnskv3rczmsf0m6aj5dksqr58m3",
},
{
OperatorAddress: "persistencevaloper10ngyx42lfpylpllm4k3g7fz4gufnt3ptyhm5pn",
},
{
OperatorAddress: "persistencevaloper10fcwju2n8vvffkp8judj3skqpvnphasxjar5yx",
},
}

func TestDivideByWeight(t *testing.T) {
testCases := []struct {
Expand Down Expand Up @@ -417,7 +415,8 @@ func TestDivideByCurrentWeight(t *testing.T) {
totalLiquidTokens = totalLiquidTokens.Add(v.LiquidTokens)
liquidTokenMap[v.OperatorAddress] = v.LiquidTokens
lvs = append(lvs, types.LiquidValidator{
OperatorAddress: v.OperatorAddress})
OperatorAddress: v.OperatorAddress,
})
}
outputs, crumb := types.DivideByCurrentWeight(lvs, tc.addStakingAmt, totalLiquidTokens, liquidTokenMap)
for _, v := range outputs {
Expand Down
Loading

0 comments on commit 304f6e4

Please sign in to comment.