Skip to content

Commit

Permalink
Merge branch 'master' into paul/support-hex-address-chain-link
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Dec 20, 2021
2 parents 60f40f5 + be5cb41 commit 9f8c160
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 74 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,15 @@ jobs:

- name: Filter out DONTCOVER 🔍
run: |
module=$(cat go.mod | grep module)
module=$(echo $module | sed "s/module //g")
excludelist="$(find ./ -type f -name '*.go' | xargs grep -l 'DONTCOVER')"
excludelist+=" $(find ./ -type f -name '*.pb.go')"
excludelist+=" $(find ./ -type f -name '*.pb.gw.go')"
excludelist+=" $(find ./ -type f -path './tests/mocks/*.go')"
for filename in ${excludelist}; do
filename=$(echo $filename | sed 's/^./github.com\/desmos-labs\/desmos/g')
filename=$(echo $filename | sed "s|^.|$module|g")
echo "Excluding ${filename} from coverage report..."
sed -i.bak "/$(echo $filename | sed 's/\//\\\//g')/d" coverage.txt
done
Expand Down
103 changes: 47 additions & 56 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,7 @@ var (
vesting.AppModuleBasic{},

// Custom modules
//fees.AppModuleBasic{},
//posts.AppModuleBasic{},
profiles.AppModuleBasic{},
//subspaces.AppModuleBasic{},
)

// Module account permissions
Expand Down Expand Up @@ -195,16 +192,16 @@ type DesmosApp struct {
BankKeeper bankkeeper.Keeper
CapabilityKeeper *capabilitykeeper.Keeper
StakingKeeper stakingkeeper.Keeper
slashingKeeper slashingkeeper.Keeper
mintKeeper mintkeeper.Keeper
distrKeeper distrkeeper.Keeper
govKeeper govkeeper.Keeper
crisisKeeper crisiskeeper.Keeper
upgradeKeeper upgradekeeper.Keeper
paramsKeeper paramskeeper.Keeper
authzKeeper authzkeeper.Keeper
SlashingKeeper slashingkeeper.Keeper
MintKeeper mintkeeper.Keeper
DistrKeeper distrkeeper.Keeper
GovKeeper govkeeper.Keeper
CrisisKeeper crisiskeeper.Keeper
UpgradeKeeper upgradekeeper.Keeper
ParamsKeeper paramskeeper.Keeper
AuthzKeeper authzkeeper.Keeper
IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
evidenceKeeper evidencekeeper.Keeper
EvidenceKeeper evidencekeeper.Keeper
TransferKeeper ibctransferkeeper.Keeper
FeeGrantKeeper feegrantkeeper.Keeper

Expand Down Expand Up @@ -278,10 +275,10 @@ func NewDesmosApp(
memKeys: memKeys,
}

app.paramsKeeper = initParamsKeeper(appCodec, legacyAmino, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey])
app.ParamsKeeper = initParamsKeeper(appCodec, legacyAmino, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey])

// set the BaseApp's parameter store
bApp.SetParamStore(app.paramsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramskeeper.ConsensusParamsKeyTable()))
bApp.SetParamStore(app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramskeeper.ConsensusParamsKeyTable()))

// add capability keeper and ScopeToModule for ibc module
app.CapabilityKeeper = capabilitykeeper.NewKeeper(appCodec, keys[capabilitytypes.StoreKey], memKeys[capabilitytypes.MemStoreKey])
Expand All @@ -302,47 +299,47 @@ func NewDesmosApp(
stakingKeeper := stakingkeeper.NewKeeper(
appCodec, keys[stakingtypes.StoreKey], app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName),
)
app.mintKeeper = mintkeeper.NewKeeper(
app.MintKeeper = mintkeeper.NewKeeper(
appCodec, keys[minttypes.StoreKey], app.GetSubspace(minttypes.ModuleName), &stakingKeeper,
app.AccountKeeper, app.BankKeeper, authtypes.FeeCollectorName,
)
app.distrKeeper = distrkeeper.NewKeeper(
app.DistrKeeper = distrkeeper.NewKeeper(
appCodec, keys[distrtypes.StoreKey], app.GetSubspace(distrtypes.ModuleName), app.AccountKeeper, app.BankKeeper,
&stakingKeeper, authtypes.FeeCollectorName, app.ModuleAccountAddrs(),
)
app.slashingKeeper = slashingkeeper.NewKeeper(
app.SlashingKeeper = slashingkeeper.NewKeeper(
appCodec, keys[slashingtypes.StoreKey], &stakingKeeper, app.GetSubspace(slashingtypes.ModuleName),
)
app.crisisKeeper = crisiskeeper.NewKeeper(
app.CrisisKeeper = crisiskeeper.NewKeeper(
app.GetSubspace(crisistypes.ModuleName), invCheckPeriod, app.BankKeeper, authtypes.FeeCollectorName,
)

app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, keys[feegrant.StoreKey], app.AccountKeeper)
app.upgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath, app.BaseApp)
app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath, app.BaseApp)
app.registerUpgradeHandlers()

// register the staking hooks
// NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks
app.StakingKeeper = *stakingKeeper.SetHooks(
stakingtypes.NewMultiStakingHooks(app.distrKeeper.Hooks(), app.slashingKeeper.Hooks()),
stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks()),
)

// Create IBC Keeper
app.IBCKeeper = ibckeeper.NewKeeper(
appCodec, keys[ibchost.StoreKey], app.GetSubspace(ibchost.ModuleName), app.StakingKeeper, app.upgradeKeeper, scopedIBCKeeper,
appCodec, keys[ibchost.StoreKey], app.GetSubspace(ibchost.ModuleName), app.StakingKeeper, app.UpgradeKeeper, scopedIBCKeeper,
)

app.authzKeeper = authzkeeper.NewKeeper(keys[authzkeeper.StoreKey], appCodec, app.BaseApp.MsgServiceRouter())
app.AuthzKeeper = authzkeeper.NewKeeper(keys[authzkeeper.StoreKey], appCodec, app.BaseApp.MsgServiceRouter())

// register the proposal types
govRouter := govtypes.NewRouter()
govRouter.AddRoute(govtypes.RouterKey, govtypes.ProposalHandler).
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.paramsKeeper)).
AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.distrKeeper)).
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.upgradeKeeper)).
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)).
AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)).
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)).
AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper))

app.govKeeper = govkeeper.NewKeeper(
app.GovKeeper = govkeeper.NewKeeper(
appCodec, keys[govtypes.StoreKey], app.GetSubspace(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper,
&stakingKeeper, govRouter,
)
Expand Down Expand Up @@ -375,10 +372,10 @@ func NewDesmosApp(

// create evidence keeper with router
evidenceKeeper := evidencekeeper.NewKeeper(
appCodec, keys[evidencetypes.StoreKey], &app.StakingKeeper, app.slashingKeeper,
appCodec, keys[evidencetypes.StoreKey], &app.StakingKeeper, app.SlashingKeeper,
)
// If evidence needs to be handled for the app, set routes in router here and seal
app.evidenceKeeper = *evidenceKeeper
app.EvidenceKeeper = *evidenceKeeper

/**** Module Options ****/

Expand All @@ -398,25 +395,22 @@ func NewDesmosApp(
vesting.NewAppModule(app.AccountKeeper, app.BankKeeper),
bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper),
capability.NewAppModule(appCodec, *app.CapabilityKeeper),
crisis.NewAppModule(&app.crisisKeeper, skipGenesisInvariants),
crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants),
feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
gov.NewAppModule(appCodec, app.govKeeper, app.AccountKeeper, app.BankKeeper),
mint.NewAppModule(appCodec, app.mintKeeper, app.AccountKeeper),
slashing.NewAppModule(appCodec, app.slashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
distr.NewAppModule(appCodec, app.distrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper),
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper),
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
upgrade.NewAppModule(app.upgradeKeeper),
evidence.NewAppModule(app.evidenceKeeper),
upgrade.NewAppModule(app.UpgradeKeeper),
evidence.NewAppModule(app.EvidenceKeeper),
ibc.NewAppModule(app.IBCKeeper),
params.NewAppModule(app.paramsKeeper),
authzmodule.NewAppModule(appCodec, app.authzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
params.NewAppModule(app.ParamsKeeper),
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
transferModule,

// Custom modules
//fees.NewAppModule(app.FeesKeeper, app.AccountKeeper),
//posts.NewAppModule(app.appCodec, app.postsKeeper, app.AccountKeeper, app.BankKeeper),
profilesModule,
//subspaces.NewAppModule(app.appCodec, app.SubspaceKeeper, app.AccountKeeper, app.BankKeeper),
)

// During begin block slashing happens after distr.BeginBlocker so that
Expand Down Expand Up @@ -448,7 +442,7 @@ func NewDesmosApp(
crisistypes.ModuleName,
)

app.mm.RegisterInvariants(&app.crisisKeeper)
app.mm.RegisterInvariants(&app.CrisisKeeper)
app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino)
app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())
app.mm.RegisterServices(app.configurator)
Expand All @@ -465,22 +459,19 @@ func NewDesmosApp(
bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper),
capability.NewAppModule(appCodec, *app.CapabilityKeeper),
feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
gov.NewAppModule(appCodec, app.govKeeper, app.AccountKeeper, app.BankKeeper),
mint.NewAppModule(appCodec, app.mintKeeper, app.AccountKeeper),
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper),
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper),
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
distr.NewAppModule(appCodec, app.distrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
slashing.NewAppModule(appCodec, app.slashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
params.NewAppModule(app.paramsKeeper),
evidence.NewAppModule(app.evidenceKeeper),
authzmodule.NewAppModule(appCodec, app.authzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
params.NewAppModule(app.ParamsKeeper),
evidence.NewAppModule(app.EvidenceKeeper),
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
ibc.NewAppModule(app.IBCKeeper),
transferModule,

// Custom modules
//fees.NewAppModule(app.FeesKeeper, app.AccountKeeper),
//posts.NewAppModule(app.appCodec, app.postsKeeper, app.AccountKeeper, app.BankKeeper),
profiles.NewAppModule(app.appCodec, legacyAmino, app.ProfileKeeper, app.AccountKeeper, app.BankKeeper),
//subspaces.NewAppModule(app.appCodec, app.SubspaceKeeper, app.AccountKeeper, app.BankKeeper),
)

app.sm.RegisterStoreDecoders()
Expand Down Expand Up @@ -560,7 +551,7 @@ func (app *DesmosApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) ab
if err := json.Unmarshal(req.AppStateBytes, &genesisState); err != nil {
panic(err)
}
app.upgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap())
app.UpgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap())
return app.mm.InitGenesis(ctx, app.appCodec, genesisState)
}

Expand Down Expand Up @@ -625,7 +616,7 @@ func (app *DesmosApp) GetMemKey(storeKey string) *sdk.MemoryStoreKey {
//
// NOTE: This is solely to be used for testing purposes.
func (app *DesmosApp) GetSubspace(moduleName string) paramstypes.Subspace {
subspace, _ := app.paramsKeeper.GetSubspace(moduleName)
subspace, _ := app.ParamsKeeper.GetSubspace(moduleName)
return subspace
}

Expand Down Expand Up @@ -666,16 +657,16 @@ func (app *DesmosApp) RegisterTendermintService(clientCtx client.Context) {
}

func (app *DesmosApp) registerUpgradeHandlers() {
app.upgradeKeeper.SetUpgradeHandler("v2.3.1", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
app.UpgradeKeeper.SetUpgradeHandler("v2.3.1", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
return app.mm.RunMigrations(ctx, app.configurator, fromVM)
})

upgradeInfo, err := app.upgradeKeeper.ReadUpgradeInfoFromDisk()
upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
panic(err)
}

if upgradeInfo.Name == "v2.3.1" && !app.upgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
if upgradeInfo.Name == "v2.3.1" && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := storetypes.StoreUpgrades{}

// Configure store loader that checks if version == upgradeHeight and applies store upgrades
Expand Down
28 changes: 14 additions & 14 deletions app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (app *DesmosApp) ExportAppStateAndValidators(
func (app *DesmosApp) prepForZeroHeightGenesis(ctx sdk.Context, jailWhiteList []string) {
applyWhiteList := false

//Check if there is a whitelist
// Check if there is a whitelist
if len(jailWhiteList) > 0 {
applyWhiteList = true
}
Expand All @@ -74,13 +74,13 @@ func (app *DesmosApp) prepForZeroHeightGenesis(ctx sdk.Context, jailWhiteList []
}

/* Just to be safe, assert the invariants on current state. */
app.crisisKeeper.AssertInvariants(ctx)
app.CrisisKeeper.AssertInvariants(ctx)

/* Handle fee distribution state. */

// withdraw all validator commission
app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
_, err := app.distrKeeper.WithdrawValidatorCommission(ctx, val.GetOperator())
_, err := app.DistrKeeper.WithdrawValidatorCommission(ctx, val.GetOperator())
// we don't care if the error is telling us there are no commissions, as currently we have no inflation
// TODO: remove this once we add inflation (if ever)
if err != nil && err != distrtypes.ErrNoValidatorCommission {
Expand All @@ -102,14 +102,14 @@ func (app *DesmosApp) prepForZeroHeightGenesis(ctx sdk.Context, jailWhiteList []
if err != nil {
panic(err)
}
_, _ = app.distrKeeper.WithdrawDelegationRewards(ctx, delAddr, valAddr)
_, _ = app.DistrKeeper.WithdrawDelegationRewards(ctx, delAddr, valAddr)
}

// clear validator slash events
app.distrKeeper.DeleteAllValidatorSlashEvents(ctx)
app.DistrKeeper.DeleteAllValidatorSlashEvents(ctx)

// clear validator historical rewards
app.distrKeeper.DeleteAllValidatorHistoricalRewards(ctx)
app.DistrKeeper.DeleteAllValidatorHistoricalRewards(ctx)

// set context height to zero
height := ctx.BlockHeight()
Expand All @@ -119,12 +119,12 @@ func (app *DesmosApp) prepForZeroHeightGenesis(ctx sdk.Context, jailWhiteList []
app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {

// donate any unwithdrawn outstanding reward fraction tokens to the community pool
scraps := app.distrKeeper.GetValidatorOutstandingRewardsCoins(ctx, val.GetOperator())
feePool := app.distrKeeper.GetFeePool(ctx)
scraps := app.DistrKeeper.GetValidatorOutstandingRewardsCoins(ctx, val.GetOperator())
feePool := app.DistrKeeper.GetFeePool(ctx)
feePool.CommunityPool = feePool.CommunityPool.Add(scraps...)
app.distrKeeper.SetFeePool(ctx, feePool)
app.DistrKeeper.SetFeePool(ctx, feePool)

app.distrKeeper.Hooks().AfterValidatorCreated(ctx, val.GetOperator())
app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, val.GetOperator())
return false
})

Expand All @@ -138,8 +138,8 @@ func (app *DesmosApp) prepForZeroHeightGenesis(ctx sdk.Context, jailWhiteList []
if err != nil {
panic(err)
}
app.distrKeeper.Hooks().BeforeDelegationCreated(ctx, delAddr, valAddr)
app.distrKeeper.Hooks().AfterDelegationModified(ctx, delAddr, valAddr)
app.DistrKeeper.Hooks().BeforeDelegationCreated(ctx, delAddr, valAddr)
app.DistrKeeper.Hooks().AfterDelegationModified(ctx, delAddr, valAddr)
}

// reset context height
Expand Down Expand Up @@ -197,11 +197,11 @@ func (app *DesmosApp) prepForZeroHeightGenesis(ctx sdk.Context, jailWhiteList []
/* Handle slashing state. */

// reset start height on signing infos
app.slashingKeeper.IterateValidatorSigningInfos(
app.SlashingKeeper.IterateValidatorSigningInfos(
ctx,
func(addr sdk.ConsAddress, info slashingtypes.ValidatorSigningInfo) (stop bool) {
info.StartHeight = 0
app.slashingKeeper.SetValidatorSigningInfo(ctx, addr, info)
app.SlashingKeeper.SetValidatorSigningInfo(ctx, addr, info)
return false
},
)
Expand Down
4 changes: 2 additions & 2 deletions x/profiles/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry)
types.RegisterInterfaces(registry)
}

//____________________________________________________________________________
// --------------------------------------------------------------------------------------------------------------------

// AppModule implements an application module for the profiles module.
type AppModule struct {
Expand Down Expand Up @@ -193,7 +193,7 @@ func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.Valid
return []abci.ValidatorUpdate{}
}

//____________________________________________________________________________
// --------------------------------------------------------------------------------------------------------------------

// AppModuleSimulation defines the module simulation functions used by the profiles module.
type AppModuleSimulation struct{}
Expand Down
2 changes: 1 addition & 1 deletion x/profiles/types/models_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const (
// Default profile paramsModule
var (
DefaultMinNicknameLength = sdk.NewInt(2)
DefaultMaxNicknameLength = sdk.NewInt(1000) //longest name on earth count 954 chars
DefaultMaxNicknameLength = sdk.NewInt(1000) // Longest name on earth count 954 chars
DefaultRegEx = `^[A-Za-z0-9_]+$`
DefaultMinDTagLength = sdk.NewInt(3)
DefaultMaxDTagLength = sdk.NewInt(30)
Expand Down

0 comments on commit 9f8c160

Please sign in to comment.