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

feat(app): add monitoringp module #721

Merged
merged 7 commits into from
Apr 15, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
51 changes: 41 additions & 10 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ import (
"github.com/tendermint/spn/docs"
spntypes "github.com/tendermint/spn/pkg/types"

monitoringpmodule "github.com/tendermint/spn/x/monitoringp"
monitoringpmodulekeeper "github.com/tendermint/spn/x/monitoringp/keeper"
monitoringpmoduletypes "github.com/tendermint/spn/x/monitoringp/types"

monitoringcmodule "github.com/tendermint/spn/x/monitoringc"
monitoringcmodulekeeper "github.com/tendermint/spn/x/monitoringc/keeper"
monitoringcmoduletypes "github.com/tendermint/spn/x/monitoringc/types"
Expand Down Expand Up @@ -175,22 +179,25 @@ var (
launchmodule.AppModuleBasic{},
campaignmodule.AppModuleBasic{},
monitoringcmodule.AppModuleBasic{},
monitoringpmodule.AppModuleBasic{},
rewardmodule.AppModuleBasic{},
fundraisingmodule.AppModuleBasic{},
)

// module account permissions
maccPerms = map[string][]string{
authtypes.FeeCollectorName: nil,
distrtypes.ModuleName: nil,
minttypes.ModuleName: {authtypes.Minter},
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
govtypes.ModuleName: {authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
campaignmoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner},
rewardmoduletypes.ModuleName: nil,
fundraisingtypes.ModuleName: nil,
authtypes.FeeCollectorName: nil,
distrtypes.ModuleName: nil,
minttypes.ModuleName: {authtypes.Minter},
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
govtypes.ModuleName: {authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
campaignmoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner},
rewardmoduletypes.ModuleName: nil,
fundraisingtypes.ModuleName: nil,
monitoringcmoduletypes.ModuleName: nil,
monitoringpmoduletypes.ModuleName: nil,
// this line is used by starport scaffolding # stargate/app/maccPerms
}
)
Expand Down Expand Up @@ -256,6 +263,7 @@ type App struct {
LaunchKeeper launchmodulekeeper.Keeper
CampaignKeeper campaignmodulekeeper.Keeper
MonitoringcKeeper monitoringcmodulekeeper.Keeper
MonitoringpKeeper monitoringpmodulekeeper.Keeper
RewardKeeper rewardmodulekeeper.Keeper
ParticipationKeeper participationmodulekeeper.Keeper
// this line is used by starport scaffolding # stargate/app/keeperDeclaration
Expand Down Expand Up @@ -312,6 +320,7 @@ func New(
launchmoduletypes.StoreKey,
campaignmoduletypes.StoreKey,
monitoringcmoduletypes.StoreKey,
monitoringpmoduletypes.StoreKey,
rewardmoduletypes.StoreKey,
fundraisingtypes.StoreKey,
participationmoduletypes.StoreKey,
Expand Down Expand Up @@ -486,6 +495,21 @@ func New(
app.LaunchKeeper.SetMonitoringcKeeper(app.MonitoringcKeeper)
monitoringcModule := monitoringcmodule.NewAppModule(appCodec, app.MonitoringcKeeper, app.AuthKeeper, app.BankKeeper)

scopedMonitoringKeeper := app.CapabilityKeeper.ScopeToModule(monitoringpmoduletypes.ModuleName)
app.MonitoringpKeeper = *monitoringpmodulekeeper.NewKeeper(
appCodec,
keys[monitoringpmoduletypes.StoreKey],
keys[monitoringpmoduletypes.MemStoreKey],
app.GetSubspace(monitoringpmoduletypes.ModuleName),
app.StakingKeeper,
app.IBCKeeper.ClientKeeper,
app.IBCKeeper.ConnectionKeeper,
app.IBCKeeper.ChannelKeeper,
&app.IBCKeeper.PortKeeper,
scopedMonitoringKeeper,
)
monitoringpModule := monitoringpmodule.NewAppModule(appCodec, app.MonitoringpKeeper)

app.ParticipationKeeper = *participationmodulekeeper.NewKeeper(
appCodec,
keys[participationmoduletypes.StoreKey],
Expand All @@ -501,6 +525,7 @@ func New(
ibcRouter := ibcporttypes.NewRouter()
ibcRouter.AddRoute(ibctransfertypes.ModuleName, app.transferModule)
ibcRouter.AddRoute(monitoringcmoduletypes.ModuleName, monitoringcModule)
ibcRouter.AddRoute(monitoringpmoduletypes.ModuleName, monitoringpModule)
// this line is used by starport scaffolding # ibc/app/router
app.IBCKeeper.SetRouter(ibcRouter)

Expand Down Expand Up @@ -539,6 +564,7 @@ func New(
launchmodule.NewAppModule(appCodec, app.LaunchKeeper, app.AuthKeeper, app.BankKeeper),
campaignmodule.NewAppModule(appCodec, app.CampaignKeeper, app.AuthKeeper, app.BankKeeper, app.ProfileKeeper),
monitoringcModule,
monitoringpModule,
rewardmodule.NewAppModule(appCodec, app.RewardKeeper, app.AuthKeeper, app.BankKeeper),
fundraisingmodule.NewAppModule(appCodec, app.FundraisingKeeper, app.AuthKeeper, app.BankKeeper, app.DistrKeeper),
participationmodule.NewAppModule(appCodec, app.ParticipationKeeper, app.AuthKeeper, app.BankKeeper, app.FundraisingKeeper),
Expand Down Expand Up @@ -573,6 +599,7 @@ func New(
rewardmoduletypes.ModuleName,
campaignmoduletypes.ModuleName,
monitoringcmoduletypes.ModuleName,
monitoringpmoduletypes.ModuleName,
participationmoduletypes.ModuleName,
launchmoduletypes.ModuleName,
)
Expand Down Expand Up @@ -601,6 +628,7 @@ func New(
rewardmoduletypes.ModuleName,
campaignmoduletypes.ModuleName,
monitoringcmoduletypes.ModuleName,
monitoringpmoduletypes.ModuleName,
participationmoduletypes.ModuleName,
launchmoduletypes.ModuleName,
)
Expand Down Expand Up @@ -633,6 +661,7 @@ func New(
launchmoduletypes.ModuleName,
campaignmoduletypes.ModuleName,
monitoringcmoduletypes.ModuleName,
monitoringpmoduletypes.ModuleName,
rewardmoduletypes.ModuleName,
fundraisingtypes.ModuleName,
participationmoduletypes.ModuleName,
Expand Down Expand Up @@ -665,6 +694,7 @@ func New(
rewardmodule.NewAppModule(appCodec, app.RewardKeeper, app.AuthKeeper, app.BankKeeper),
participationmodule.NewAppModule(appCodec, app.ParticipationKeeper, app.AuthKeeper, app.BankKeeper, app.FundraisingKeeper),
fundraisingmodule.NewAppModule(appCodec, app.FundraisingKeeper, app.AuthKeeper, app.BankKeeper, app.DistrKeeper),
monitoringpModule,
)
app.sm.RegisterStoreDecoders()

Expand Down Expand Up @@ -855,6 +885,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(launchmoduletypes.ModuleName)
paramsKeeper.Subspace(campaignmoduletypes.ModuleName)
paramsKeeper.Subspace(monitoringcmoduletypes.ModuleName)
paramsKeeper.Subspace(monitoringpmoduletypes.ModuleName)
paramsKeeper.Subspace(rewardmoduletypes.ModuleName)
paramsKeeper.Subspace(fundraisingtypes.ModuleName)
paramsKeeper.Subspace(participationmoduletypes.ModuleName)
Expand Down
6 changes: 6 additions & 0 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ genesis:
auction_creation_fee:
- "amount": "100"
"denom": "uspn"
monitoringp:
params:
lastBlockHeight: "1"
consumerChainID: "orbit-1"
consumerUnbondingPeriod: "2"
consumerRevisionHeight: "1"
participation:
params:
allocationPrice:
Expand Down
11 changes: 10 additions & 1 deletion localnet/genesis_template.json
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,19 @@
"monitoringHistoryList": [],
"params": {
},
"port_id": "monitoring",
"port_id": "monitoringc",
"providerClientIDList": [],
"verifiedClientIDList": []
},
"monitoringp": {
"params": {
"lastBlockHeight": "1",
"consumerChainID": "orbit-1",
"consumerUnbondingPeriod": "2",
"consumerRevisionHeight": 1
},
"port_id": "monitoringp"
},
"params": null,
"participation": {
"params": {
Expand Down
2 changes: 1 addition & 1 deletion x/monitoringc/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const (
Version = "monitoring-1"

// PortID is the default port id that module binds to
PortID = "monitoring"
PortID = "monitoringc"

// VerifiedClientIDKeyPrefix is the prefix to retrieve all VerifiedClientID
VerifiedClientIDKeyPrefix = "VerifiedClientID/value/"
Expand Down
2 changes: 1 addition & 1 deletion x/monitoringp/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const (
Version = "monitoring-1"

// PortID is the default port id that module binds to
PortID = "monitoring"
PortID = "monitoringp"

// ConsumerClientIDKey allows to retrieve in the store the client ID used for the IBC communication with the Consumer Chain
ConsumerClientIDKey = "ConsumerClientID/value/"
Expand Down
4 changes: 2 additions & 2 deletions x/monitoringp/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func validateLastBlockHeight(i interface{}) error {
}

if lastBlockHeight <= 0 {
return errors.New("last block height can't be 0 or negative")
return errors.New("last block height can't 0 or negative")
aljo242 marked this conversation as resolved.
Show resolved Hide resolved
}

return nil
Expand Down Expand Up @@ -182,7 +182,7 @@ func validateConsumerRevisionHeight(i interface{}) error {
}

if revisionHeight == 0 {
return fmt.Errorf("minimal unbonding period is %d", spntypes.MinimalUnbondingPeriod)
return fmt.Errorf("minimal revision height is %d", 1)
}

return nil
Expand Down