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: relationships module #750

Merged
merged 64 commits into from
Mar 1, 2022
Merged
Show file tree
Hide file tree
Changes from 63 commits
Commits
Show all changes
64 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
4c62789
chore: updated Proto packages to match real versions
RiccardoM Jan 26, 2022
1615ab3
chore: renamed subspace fields to subspace_id inside x/profiles Proto…
RiccardoM Jan 26, 2022
5dd2122
small lint
RiccardoM Jan 26, 2022
e422c23
chore: replaced all expErr with shouldErr
RiccardoM Jan 26, 2022
4fc9328
moved all the relationships-related things into the new x/relationshi…
RiccardoM Jan 26, 2022
ee244a9
Merge branch 'master' of github.com:desmos-labs/desmos into riccardo/…
RiccardoM Feb 22, 2022
d53accf
Updated Swagger definition
RiccardoM Feb 22, 2022
a85a164
fixed compilation errors
RiccardoM Feb 22, 2022
93608a6
improving tests
RiccardoM Feb 22, 2022
b437666
Merge remote-tracking branch 'origin/riccardo/relationships-module' i…
RiccardoM Feb 22, 2022
3f40b9e
fixed unit tests
RiccardoM Feb 23, 2022
c4e8f5e
Merge branch 'master' of github.com:desmos-labs/desmos into riccardo/…
RiccardoM Feb 23, 2022
2521bf9
fixed simulation operations
RiccardoM Feb 23, 2022
df349dd
added the filtering for relationships during the migration
RiccardoM Feb 23, 2022
3556916
updated to Cosmos v0.45.x and added a custom OrderMigrations
RiccardoM Feb 23, 2022
cc50c97
fixed tests
RiccardoM Feb 23, 2022
86289a7
added missing profiles decoder tests
RiccardoM Feb 24, 2022
8e6f763
added missing store tests
RiccardoM Feb 24, 2022
db121e9
added missing DONTCOVER directives
RiccardoM Feb 24, 2022
f4055b4
bring back build step for sims tests
RiccardoM Feb 24, 2022
2110e42
increased liveliness test duration
RiccardoM Feb 24, 2022
bd102e3
use go 1.17 instead of 1.15
RiccardoM Feb 24, 2022
4078c7b
small change to trigger tests
RiccardoM Feb 24, 2022
9ef4cf6
added mint and authz to store keys
RiccardoM Feb 25, 2022
4173742
improved the performance of user groups reading
RiccardoM Feb 25, 2022
8dc035d
improved the subspace simulations operations
RiccardoM Feb 25, 2022
aa761b1
improved the performance to iterator-related methods inside the suspa…
RiccardoM Feb 25, 2022
b5d8e52
reduced liveliness test
RiccardoM Feb 25, 2022
8e01fef
changed how Desmos is built for Linux by using a Docker container
RiccardoM Feb 25, 2022
d26d36c
fixed Docker
RiccardoM Feb 25, 2022
654fe44
updated make-build
RiccardoM Feb 25, 2022
9d2b3b9
trying to fix build-linux
RiccardoM Feb 25, 2022
447a887
trying to fix build-linux
RiccardoM Feb 25, 2022
ffd76a3
trying to fix build-linux
RiccardoM Feb 25, 2022
355b3a7
updated Proto field numberings
RiccardoM Feb 28, 2022
7ee6fb7
fixed handler comment
RiccardoM Feb 28, 2022
cda19c2
added the subspace hook to delete relationships and blocks when a sub…
RiccardoM Feb 28, 2022
f91d6bc
fixed hooks tests
RiccardoM Feb 28, 2022
a46f4c3
Merge branch 'riccardo/fix-actions' of github.com:desmos-labs/desmos …
RiccardoM Feb 28, 2022
c62adf3
fixed simulation tests
RiccardoM Feb 28, 2022
82e9d2b
fixed simulation tests
RiccardoM Feb 28, 2022
78635ba
added changeset entry
RiccardoM Feb 28, 2022
8c0a088
Merge branch 'master' of github.com:desmos-labs/desmos into riccardo/…
RiccardoM Mar 1, 2022
69cb74d
merged master
RiccardoM Mar 1, 2022
69f3334
Merge branch 'master' into riccardo/relationships-module
mergify[bot] Mar 1, 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: feat
module: none
pull_request: 750
description: Split relationships and user blocks into the new x/relationships module
backward_compatible: false
date: 2022-02-28T13:15:58.416244744Z
164 changes: 145 additions & 19 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@ import (
"path/filepath"
"strings"

profilesv2 "github.com/desmos-labs/desmos/v2/x/profiles/legacy/v2"

"github.com/desmos-labs/desmos/v2/x/relationships"
relationshipstypes "github.com/desmos-labs/desmos/v2/x/relationships/types"

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

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

"github.com/cosmos/cosmos-sdk/x/auth/vesting"
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
"github.com/cosmos/cosmos-sdk/x/authz"
"github.com/cosmos/cosmos-sdk/x/feegrant"

Expand Down Expand Up @@ -86,6 +92,7 @@ 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"
relationshipskeeper "github.com/desmos-labs/desmos/v2/x/relationships/keeper"
subspaceskeeper "github.com/desmos-labs/desmos/v2/x/subspaces/keeper"
subspacestypes "github.com/desmos-labs/desmos/v2/x/subspaces/types"

Expand Down Expand Up @@ -213,6 +220,7 @@ var (

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

Expand Down Expand Up @@ -273,8 +281,9 @@ type DesmosApp struct {
ScopedWasmKeeper capabilitykeeper.ScopedKeeper

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

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

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

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

// Create the relationships keeper
app.RelationshipsKeeper = relationshipskeeper.NewKeeper(
appCodec,
keys[relationshipstypes.StoreKey],
&subspacesKeeper,
)

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

// Register the subspaces hooks
// NOTE: subspacesKeeper above is passed by reference, so that it will contain these hooks
app.SubspacesKeeper = *subspacesKeeper.SetHooks(
subspacestypes.NewMultiSubspacesHooks(app.RelationshipsKeeper.Hooks()),
)

// Create static IBC router, add transfer route, then set and seal it
ibcRouter := porttypes.NewRouter()
Expand Down Expand Up @@ -525,6 +553,7 @@ func NewDesmosApp(
// Custom modules
subspaces.NewAppModule(appCodec, app.SubspacesKeeper, app.AccountKeeper, app.BankKeeper),
profilesModule,
relationships.NewAppModule(appCodec, app.RelationshipsKeeper, app.SubspacesKeeper, profilesv2.NewKeeper(keys[profilestypes.StoreKey], appCodec), app.AccountKeeper, app.BankKeeper),
)

// During begin block slashing happens after distr.BeginBlocker so that
Expand All @@ -533,25 +562,117 @@ func NewDesmosApp(
// NOTE: staking module is required if HistoricalEntries param > 0
// NOTE: capability module's beginblocker must come before any modules using capabilities (e.g. IBC)
app.mm.SetOrderBeginBlockers(
upgradetypes.ModuleName, capabilitytypes.ModuleName, minttypes.ModuleName, distrtypes.ModuleName, slashingtypes.ModuleName,
evidencetypes.ModuleName, stakingtypes.ModuleName, ibchost.ModuleName,
upgradetypes.ModuleName,
capabilitytypes.ModuleName,
minttypes.ModuleName,
distrtypes.ModuleName,
slashingtypes.ModuleName,
evidencetypes.ModuleName,
stakingtypes.ModuleName,
authtypes.ModuleName,
banktypes.ModuleName,
govtypes.ModuleName,
crisistypes.ModuleName,
genutiltypes.ModuleName,
authz.ModuleName,
feegrant.ModuleName,
paramstypes.ModuleName,
vestingtypes.ModuleName,
ibchost.ModuleName,
ibctransfertypes.ModuleName,
wasm.ModuleName,

subspacestypes.ModuleName,
relationshipstypes.ModuleName,
profilestypes.ModuleName,
)
app.mm.SetOrderEndBlockers(
crisistypes.ModuleName,
govtypes.ModuleName,
stakingtypes.ModuleName,
capabilitytypes.ModuleName,
authtypes.ModuleName,
banktypes.ModuleName,
distrtypes.ModuleName,
slashingtypes.ModuleName,
minttypes.ModuleName,
genutiltypes.ModuleName,
evidencetypes.ModuleName,
authz.ModuleName,
feegrant.ModuleName,
paramstypes.ModuleName,
upgradetypes.ModuleName,
vestingtypes.ModuleName,
ibchost.ModuleName,
ibctransfertypes.ModuleName,
wasm.ModuleName,

subspacestypes.ModuleName,
relationshipstypes.ModuleName,
profilestypes.ModuleName,
)
app.mm.SetOrderEndBlockers(crisistypes.ModuleName, govtypes.ModuleName, stakingtypes.ModuleName)

// NOTE: The genutils module must occur after staking so that pools are
// properly initialized with tokens from genesis accounts.
// NOTE: The genutils module must also occur after auth so that it can access the params from auth.
// NOTE: Capability module must occur first so that it can initialize any capabilities
// so that other modules that want to create or claim capabilities afterwards in InitChain
// can do so safely.
// NOTE: The crisis module should occur after all other modules to run the invariants at genesis correctly
app.mm.SetOrderInitGenesis(
capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, distrtypes.ModuleName, stakingtypes.ModuleName,
slashingtypes.ModuleName, govtypes.ModuleName, minttypes.ModuleName,
ibchost.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName, ibctransfertypes.ModuleName,
feegrant.ModuleName, wasm.ModuleName,
capabilitytypes.ModuleName,
authtypes.ModuleName,
banktypes.ModuleName,
distrtypes.ModuleName,
stakingtypes.ModuleName,
slashingtypes.ModuleName,
govtypes.ModuleName,
minttypes.ModuleName,
genutiltypes.ModuleName,
evidencetypes.ModuleName,
authz.ModuleName,
feegrant.ModuleName,
paramstypes.ModuleName,
upgradetypes.ModuleName,
vestingtypes.ModuleName,
ibchost.ModuleName,
ibctransfertypes.ModuleName,
wasm.ModuleName,

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

crisistypes.ModuleName,
)

// NOTE: The auth module must occur before everyone else. All other modules can be sorted
// alphabetically (default order)
// NOTE: The relationships module must occur before the profiles module, or all relationships will be deleted
app.mm.SetOrderMigrations(
authtypes.ModuleName,
authz.ModuleName,
banktypes.ModuleName,
capabilitytypes.ModuleName,
distrtypes.ModuleName,
evidencetypes.ModuleName,
feegrant.ModuleName,
genutiltypes.ModuleName,
govtypes.ModuleName,
ibchost.ModuleName,
minttypes.ModuleName,
slashingtypes.ModuleName,
stakingtypes.ModuleName,
ibctransfertypes.ModuleName,
paramstypes.ModuleName,
upgradetypes.ModuleName,
vestingtypes.ModuleName,
wasm.ModuleName,

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

crisistypes.ModuleName,
)
Expand Down Expand Up @@ -586,8 +707,9 @@ func NewDesmosApp(
wasm.NewAppModule(appCodec, &app.WasmKeeper, app.StakingKeeper),

// Custom modules
subspaces.NewAppModule(app.appCodec, app.SubspacesKeeper, app.AccountKeeper, app.BankKeeper),
profiles.NewAppModule(app.appCodec, legacyAmino, app.ProfileKeeper, app.SubspacesKeeper, app.AccountKeeper, app.BankKeeper),
subspaces.NewAppModule(appCodec, app.SubspacesKeeper, app.AccountKeeper, app.BankKeeper),
profilesModule,
relationships.NewAppModule(appCodec, app.RelationshipsKeeper, app.SubspacesKeeper, profilesv2.NewKeeper(keys[profilestypes.StoreKey], appCodec), app.AccountKeeper, app.BankKeeper),
)

app.sm.RegisterStoreDecoders()
Expand Down Expand Up @@ -780,6 +902,9 @@ func (app *DesmosApp) RegisterTendermintService(clientCtx client.Context) {

func (app *DesmosApp) registerUpgradeHandlers() {
app.UpgradeKeeper.SetUpgradeHandler("v3.0.0", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
// Set the initial version of the x/relationships module to 1 so that we can migrate to 2
fromVM[relationshipstypes.ModuleName] = 1

// 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 @@ -794,6 +919,7 @@ func (app *DesmosApp) registerUpgradeHandlers() {
Added: []string{
wasm.ModuleName,
subspacestypes.ModuleName,
relationshipstypes.ModuleName,
},
}

Expand Down
Loading