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: ADR-006: Subspaces module #728

Merged
merged 49 commits into from
Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
10efacc
added the Proto definitions of the subspaces types and messages
RiccardoM Jan 14, 2022
32f7981
improved the Proto file definition
RiccardoM Jan 14, 2022
9293ae2
improved the Proto file definition
RiccardoM Jan 17, 2022
ed8e474
started working on the implementation of the message server methods
RiccardoM Jan 17, 2022
b0f4f61
more work on the handling of messages
RiccardoM Jan 18, 2022
fca2aa9
added unit tests for subspaces and permissions
RiccardoM Jan 19, 2022
e08f3b3
completed the keeper package tests
RiccardoM Jan 21, 2022
3fe18f4
completed tests for the types package
RiccardoM Jan 21, 2022
5a3362f
Merge branch 'master' of github.com:desmos-labs/desmos into riccardo/…
RiccardoM Jan 21, 2022
735a1fd
added the CLI tests
RiccardoM Jan 21, 2022
a4d22bd
added the integration tests
RiccardoM Jan 24, 2022
78a5499
added changeset entry
RiccardoM Jan 24, 2022
8233131
updated x/profiles to use the correct type for subspaces ids
RiccardoM Jan 24, 2022
10e2a71
added initial subspaces id to the subspaces genesis
RiccardoM Jan 24, 2022
c7006d3
fixed simulation tests
RiccardoM Jan 24, 2022
2b04da8
added changeset entry for x/profiles
RiccardoM Jan 24, 2022
d28fef6
fixed formatting
RiccardoM Jan 24, 2022
5a557c3
added migration for both modules
RiccardoM Jan 25, 2022
7d91aed
fixed lint
RiccardoM Jan 26, 2022
ff6c409
fixed suggested typos
RiccardoM Jan 27, 2022
3620cce
fixed group name checking inside genesis
RiccardoM Jan 27, 2022
96f4e09
generated updated Swagger file
RiccardoM Jan 27, 2022
0e4b722
fixed the blocks and relationships migration
RiccardoM Jan 27, 2022
32a545e
added the ability to delete a subspace
RiccardoM Jan 27, 2022
12a14c1
removed begin blocker todo
RiccardoM Jan 27, 2022
e68ffdd
added store tests
RiccardoM Jan 27, 2022
0b0ecc3
fixed comments
RiccardoM Jan 27, 2022
3298147
implemented the user groups
RiccardoM Jan 27, 2022
96cc2e5
lint and format
RiccardoM Jan 31, 2022
1e7a1d2
added DONTCOVER for subspaces operations files
RiccardoM Jan 31, 2022
7c1a196
added keeper tests
RiccardoM Jan 31, 2022
cd50f13
added types tests
RiccardoM Jan 31, 2022
654524a
fixed tests
RiccardoM Jan 31, 2022
b56fb41
fixed GetUsersWithPermission
RiccardoM Jan 31, 2022
84d0bb0
fixed CLI typos
RiccardoM Feb 2, 2022
bd17e42
added missing CLI test
RiccardoM Feb 2, 2022
8c302fc
fixed test name and command example
RiccardoM Feb 4, 2022
6314033
docs: fixed typos
RiccardoM Feb 7, 2022
62c5508
chore: updated query paths
RiccardoM Feb 7, 2022
00f479d
updated the UserPermissionsRequestResponse type
RiccardoM Feb 7, 2022
387ce97
moved the permission details definitions
RiccardoM Feb 7, 2022
ebdc036
fixed groups query cmd variable name
RiccardoM Feb 7, 2022
7e560b7
Update x/subspaces/keeper/groups.go
RiccardoM Feb 7, 2022
59fac8f
fixed PR suggestions
RiccardoM Feb 10, 2022
8628788
updated related ADR
RiccardoM Feb 10, 2022
a9ce20a
updated models documentation
RiccardoM Feb 10, 2022
b9e8769
updated Go version to 1.17
RiccardoM Feb 10, 2022
6c6e53b
added missing cmd tests
RiccardoM Feb 15, 2022
1a28474
Merge branch 'master' into riccardo/subspace-module-adr-impl
mergify[bot] Feb 16, 2022
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type: refactor
module: x/profiles
pull_request: 728
description: Changed the subspace id type from string to uint64
backward_compatible: false
date: 2022-01-24T15:00:42.365992872Z
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type: feat
module: x/subspaces
pull_request: 728
description: Added the new `x/subspaces` module
backward_compatible: false
date: 2022-01-24T11:13:39.102634771Z
35 changes: 27 additions & 8 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"path/filepath"
"strings"

"github.com/desmos-labs/desmos/v2/x/subspaces"

"github.com/cosmos/cosmos-sdk/version"

"github.com/cosmos/cosmos-sdk/x/auth/vesting"
Expand Down Expand Up @@ -84,6 +86,8 @@ import (
"github.com/desmos-labs/desmos/v2/x/profiles"
profileskeeper "github.com/desmos-labs/desmos/v2/x/profiles/keeper"
profilestypes "github.com/desmos-labs/desmos/v2/x/profiles/types"
subspaceskeeper "github.com/desmos-labs/desmos/v2/x/subspaces/keeper"
subspacestypes "github.com/desmos-labs/desmos/v2/x/subspaces/types"

authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
Expand Down Expand Up @@ -209,6 +213,7 @@ var (

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

// Module account permissions
Expand Down Expand Up @@ -268,7 +273,8 @@ type DesmosApp struct {
ScopedWasmKeeper capabilitykeeper.ScopedKeeper

// Custom modules
ProfileKeeper profileskeeper.Keeper
SubspacesKeeper subspaceskeeper.Keeper
ProfileKeeper profileskeeper.Keeper

// Module Manager
mm *module.Manager
Expand Down Expand Up @@ -315,7 +321,7 @@ func NewDesmosApp(
authzkeeper.StoreKey, wasm.StoreKey,

// Custom modules
profilestypes.StoreKey,
subspacestypes.StoreKey, profilestypes.StoreKey,
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
Expand Down Expand Up @@ -405,17 +411,21 @@ func NewDesmosApp(
)
transferModule := ibctransfer.NewAppModule(app.TransferKeeper)

// Create subspaces keeper
app.SubspacesKeeper = subspaceskeeper.NewKeeper(app.appCodec, keys[subspacestypes.StoreKey])

// Create profiles keeper
app.ProfileKeeper = profileskeeper.NewKeeper(
app.appCodec,
keys[profilestypes.StoreKey],
app.GetSubspace(profilestypes.ModuleName),
app.AccountKeeper,
app.SubspacesKeeper,
app.IBCKeeper.ChannelKeeper,
&app.IBCKeeper.PortKeeper,
scopedProfilesKeeper,
)
profilesModule := profiles.NewAppModule(appCodec, legacyAmino, app.ProfileKeeper, app.AccountKeeper, app.BankKeeper)
profilesModule := profiles.NewAppModule(appCodec, legacyAmino, app.ProfileKeeper, app.SubspacesKeeper, app.AccountKeeper, app.BankKeeper)

// Create static IBC router, add transfer route, then set and seal it
ibcRouter := porttypes.NewRouter()
Expand Down Expand Up @@ -513,6 +523,7 @@ func NewDesmosApp(
wasm.NewAppModule(appCodec, &app.WasmKeeper, app.StakingKeeper),

// Custom modules
subspaces.NewAppModule(appCodec, app.SubspacesKeeper, app.AccountKeeper, app.BankKeeper),
profilesModule,
)

Expand All @@ -524,6 +535,7 @@ func NewDesmosApp(
app.mm.SetOrderBeginBlockers(
upgradetypes.ModuleName, capabilitytypes.ModuleName, minttypes.ModuleName, distrtypes.ModuleName, slashingtypes.ModuleName,
evidencetypes.ModuleName, stakingtypes.ModuleName, ibchost.ModuleName,
// TODO: See if we need a BeginBlocker for the subspaces module
RiccardoM marked this conversation as resolved.
Show resolved Hide resolved
)
app.mm.SetOrderEndBlockers(crisistypes.ModuleName, govtypes.ModuleName, stakingtypes.ModuleName)

Expand All @@ -540,7 +552,7 @@ func NewDesmosApp(
feegrant.ModuleName, wasm.ModuleName,

// Custom modules
profilestypes.ModuleName,
subspacestypes.ModuleName, profilestypes.ModuleName,

crisistypes.ModuleName,
)
Expand Down Expand Up @@ -575,7 +587,8 @@ func NewDesmosApp(
wasm.NewAppModule(appCodec, &app.WasmKeeper, app.StakingKeeper),

// Custom modules
profiles.NewAppModule(app.appCodec, legacyAmino, app.ProfileKeeper, app.AccountKeeper, app.BankKeeper),
subspaces.NewAppModule(app.appCodec, app.SubspacesKeeper, app.AccountKeeper, app.BankKeeper),
profiles.NewAppModule(app.appCodec, legacyAmino, app.ProfileKeeper, app.SubspacesKeeper, app.AccountKeeper, app.BankKeeper),
)

app.sm.RegisterStoreDecoders()
Expand Down Expand Up @@ -767,7 +780,8 @@ 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("v3.0.0", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
// Nothing to do here for the x/subspaces module since the InitGenesis will be called
return app.mm.RunMigrations(ctx, app.configurator, fromVM)
})

Expand All @@ -776,8 +790,13 @@ func (app *DesmosApp) registerUpgradeHandlers() {
panic(err)
}

if upgradeInfo.Name == "v2.3.1" && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := storetypes.StoreUpgrades{}
if upgradeInfo.Name == "v3.0.0" && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := storetypes.StoreUpgrades{
Added: []string{
wasm.ModuleName,
subspacestypes.ModuleName,
},
}

// Configure store loader that checks if version == upgradeHeight and applies store upgrades
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
Expand Down
24 changes: 7 additions & 17 deletions app/params/weights.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@ package params

// Default simulation operation weights for messages
const (
DefaultWeightMsgCreatePost int = 100
DefaultWeightMsgEditPost int = 75
DefaultWeightMsgAddReaction int = 80
DefaultWeightMsgRemoveReaction int = 40
DefaultWeightMsgAnswerPoll int = 20
DefaultWeightMsgRegisterReaction int = 50

DefaultWeightMsgSaveProfile int = 80
DefaultWeightMsgDeleteProfile int = 20
DefaultWeightMsgRequestDTagTransfer int = 85
Expand All @@ -21,14 +14,11 @@ const (
DefaultWeightMsgBlockUser int = 50
DefaultWeightMsgUnblockUser int = 50

DefaultWeightMsgReportPost int = 50

DefaultWeightMsgCreateSubspace int = 100
DefaultWeightMsgEditSubspace int = 75
DefaultWeightMsgAddAmin int = 40
DefaultWeightMsgRemoveAdmin int = 40
DefaultWeightMsgRegisterUser int = 60
DefaultWeightMsgUnregisterUser int = 50
DefaultWeightMsgBanUser int = 30
DefaultWeightMsgUnbanUser int = 20
DefaultWeightMsgCreateSubspace int = 80
DefaultWeightMsgEditSubspace int = 30
DefaultWeightMsgCreateUserGroup int = 10
DefaultWeightMsgDeleteUserGroup int = 5
DefaultWeightMsgAddUserToUserGroup int = 7
DefaultWeightMsgRemoveUserFromUserGroup int = 3
DefaultWeightMsgSetPermissions int = 85
)
6 changes: 5 additions & 1 deletion app/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"path/filepath"
"testing"

subspacestypes "github.com/desmos-labs/desmos/v2/x/subspaces/types"

banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
Expand Down Expand Up @@ -217,10 +219,12 @@ func TestAppImportExport(t *testing.T) {
{app.keys[govtypes.StoreKey], newApp.keys[govtypes.StoreKey], [][]byte{}},
{app.keys[evidencetypes.StoreKey], newApp.keys[evidencetypes.StoreKey], [][]byte{}},

{app.keys[profilestypes.StoreKey], newApp.keys[profilestypes.StoreKey], [][]byte{}},
{app.keys[capabilitytypes.StoreKey], newApp.keys[capabilitytypes.StoreKey], [][]byte{}},
{app.keys[ibchost.StoreKey], newApp.keys[ibchost.StoreKey], [][]byte{}},
{app.keys[ibctransfertypes.StoreKey], newApp.keys[ibctransfertypes.StoreKey], [][]byte{}},

{app.keys[subspacestypes.StoreKey], newApp.keys[subspacestypes.StoreKey], [][]byte{}},
{app.keys[profilestypes.StoreKey], newApp.keys[profilestypes.StoreKey], [][]byte{}},
}

for _, skp := range storeKeysPrefixes {
Expand Down
Loading