Skip to content

Commit

Permalink
Merge v0.6.3
Browse files Browse the repository at this point in the history
See PR #196
  • Loading branch information
RiccardoM authored Jun 17, 2020
1 parent 44a5f06 commit faec7d3
Show file tree
Hide file tree
Showing 7 changed files with 149 additions and 103 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
- Re-introduced the on-chain government module (#173)
- Fixed reactions registration bug (#187)

# Version 0.6.3
## Changes
- Restored evidence module (#189)

# Version 0.6.2
## Changes
- Updated Cosmos to v0.38.4 (#177)
Expand Down
172 changes: 120 additions & 52 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,33 @@ import (
"io"
"os"

"github.com/cosmos/cosmos-sdk/x/gov"

"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
authvesting "github.com/cosmos/cosmos-sdk/x/auth/vesting"
"github.com/desmos-labs/desmos/x/posts"
"github.com/desmos-labs/desmos/x/profile"
"github.com/desmos-labs/desmos/x/reports"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/log"
tmos "github.com/tendermint/tendermint/libs/os"
dbm "github.com/tendermint/tm-db"

bam "github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
authvesting "github.com/cosmos/cosmos-sdk/x/auth/vesting"
"github.com/cosmos/cosmos-sdk/x/bank"
"github.com/cosmos/cosmos-sdk/x/crisis"
distr "github.com/cosmos/cosmos-sdk/x/distribution"
"github.com/cosmos/cosmos-sdk/x/evidence"
"github.com/cosmos/cosmos-sdk/x/genutil"
"github.com/cosmos/cosmos-sdk/x/gov"
"github.com/cosmos/cosmos-sdk/x/params"
paramsclient "github.com/cosmos/cosmos-sdk/x/params/client"
paramproposal "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/cosmos/cosmos-sdk/x/slashing"
"github.com/cosmos/cosmos-sdk/x/staking"
"github.com/cosmos/cosmos-sdk/x/supply"
"github.com/desmos-labs/desmos/x/magpie"
"github.com/desmos-labs/desmos/x/posts"
"github.com/desmos-labs/desmos/x/profile"
"github.com/desmos-labs/desmos/x/reports"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/log"
tmos "github.com/tendermint/tendermint/libs/os"
dbm "github.com/tendermint/tm-db"
)

const (
Expand All @@ -49,18 +47,20 @@ var (

// ModuleBasics is in charge of setting up basic module elements
ModuleBasics = module.NewBasicManager(
auth.AppModuleBasic{},
supply.AppModuleBasic{},
genutil.AppModuleBasic{},
auth.AppModuleBasic{},
bank.AppModuleBasic{},
staking.AppModuleBasic{},
distr.AppModuleBasic{},
gov.NewAppModuleBasic(
paramsclient.ProposalHandler, distr.ProposalHandler,
paramsclient.ProposalHandler,
distr.ProposalHandler,
),
params.AppModuleBasic{},
crisis.AppModuleBasic{},
slashing.AppModuleBasic{},
supply.AppModuleBasic{},
evidence.AppModuleBasic{},

// Custom modules
magpie.AppModuleBasic{},
Expand Down Expand Up @@ -104,6 +104,8 @@ type DesmosApp struct {
*bam.BaseApp
cdc *codec.Codec

invCheckPeriod uint

// sdk keys to access the substores
keys map[string]*sdk.KVStoreKey
tkeys map[string]*sdk.TransientStoreKey
Expand All @@ -121,6 +123,7 @@ type DesmosApp struct {
GovKeeper gov.Keeper
CrisisKeeper crisis.Keeper
paramsKeeper params.Keeper
evidenceKeeper evidence.Keeper

// Custom modules
magpieKeeper magpie.Keeper
Expand Down Expand Up @@ -149,20 +152,21 @@ func NewDesmosApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest
keys := sdk.NewKVStoreKeys(
bam.MainStoreKey, auth.StoreKey, staking.StoreKey,
supply.StoreKey, distr.StoreKey, slashing.StoreKey,
gov.StoreKey, params.StoreKey,
gov.StoreKey, params.StoreKey, evidence.StoreKey,

// Custom modules
magpie.StoreKey, posts.StoreKey, profile.StoreKey, reports.StoreKey,
)
tkeys := sdk.NewTransientStoreKeys(staking.TStoreKey, params.TStoreKey)
tkeys := sdk.NewTransientStoreKeys(params.TStoreKey)

// Here you initialize your application with the store keys it requires
var app = &DesmosApp{
BaseApp: bApp,
cdc: cdc,
keys: keys,
tkeys: tkeys,
subspaces: make(map[string]params.Subspace),
BaseApp: bApp,
cdc: cdc,
invCheckPeriod: invCheckPeriod,
keys: keys,
tkeys: tkeys,
subspaces: make(map[string]params.Subspace),
}

// Init params keeper and subspaces
Expand All @@ -173,65 +177,125 @@ func NewDesmosApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest
app.subspaces[distr.ModuleName] = app.paramsKeeper.Subspace(distr.DefaultParamspace)
app.subspaces[slashing.ModuleName] = app.paramsKeeper.Subspace(slashing.DefaultParamspace)
app.subspaces[gov.ModuleName] = app.paramsKeeper.Subspace(gov.DefaultParamspace).WithKeyTable(gov.ParamKeyTable())
app.subspaces[evidence.ModuleName] = app.paramsKeeper.Subspace(evidence.DefaultParamspace)
app.subspaces[crisis.ModuleName] = app.paramsKeeper.Subspace(crisis.DefaultParamspace)

// Add keepers
app.AccountKeeper = auth.NewAccountKeeper(
app.cdc, keys[auth.StoreKey], app.subspaces[auth.ModuleName], auth.ProtoBaseAccount,
app.cdc,
keys[auth.StoreKey],
app.subspaces[auth.ModuleName],
auth.ProtoBaseAccount,
)
app.BankKeeper = bank.NewBaseKeeper(
app.AccountKeeper, app.subspaces[bank.ModuleName], app.BlacklistedAccAddrs(),
app.AccountKeeper,
app.subspaces[bank.ModuleName],
app.BlacklistedAccAddrs(),
)
app.SupplyKeeper = supply.NewKeeper(
app.cdc, keys[supply.StoreKey], app.AccountKeeper, app.BankKeeper, maccPerms,
app.cdc,
keys[supply.StoreKey],
app.AccountKeeper,
app.BankKeeper,
maccPerms,
)
stakingKeeper := staking.NewKeeper(
app.cdc, keys[staking.StoreKey], app.SupplyKeeper, app.subspaces[staking.ModuleName],
app.cdc,
keys[staking.StoreKey],
app.SupplyKeeper,
app.subspaces[staking.ModuleName],
)
app.DistrKeeper = distr.NewKeeper(
app.cdc, keys[distr.StoreKey], app.subspaces[distr.ModuleName], &stakingKeeper,
app.SupplyKeeper, auth.FeeCollectorName, app.ModuleAccountAddrs(),
app.cdc,
keys[distr.StoreKey],
app.subspaces[distr.ModuleName],
&stakingKeeper,
app.SupplyKeeper,
auth.FeeCollectorName,
app.ModuleAccountAddrs(),
)
app.SlashingKeeper = slashing.NewKeeper(
app.cdc, keys[slashing.StoreKey], &stakingKeeper, app.subspaces[slashing.ModuleName],
app.cdc,
keys[slashing.StoreKey],
&stakingKeeper,
app.subspaces[slashing.ModuleName],
)
app.CrisisKeeper = crisis.NewKeeper(
app.subspaces[crisis.ModuleName], invCheckPeriod, app.SupplyKeeper, auth.FeeCollectorName,
app.subspaces[crisis.ModuleName],
app.invCheckPeriod,
app.SupplyKeeper,
auth.FeeCollectorName,
)

// register the proposal types
// Create evidence keeper with router
evidenceKeeper := evidence.NewKeeper(
app.cdc,
keys[evidence.StoreKey],
app.subspaces[evidence.ModuleName],
&app.stakingKeeper,
app.SlashingKeeper,
)
evidenceRouter := evidence.NewRouter()
evidenceKeeper.SetRouter(evidenceRouter)
app.evidenceKeeper = *evidenceKeeper

// Create gov keeper with router
govRouter := gov.NewRouter()
govRouter.AddRoute(gov.RouterKey, gov.ProposalHandler).
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.paramsKeeper))
govRouter.
AddRoute(gov.RouterKey, gov.ProposalHandler).
AddRoute(params.RouterKey, params.NewParamChangeProposalHandler(app.paramsKeeper)).
AddRoute(distr.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper))

app.GovKeeper = gov.NewKeeper(
app.cdc,
keys[gov.StoreKey],
app.subspaces[gov.ModuleName],
app.SupplyKeeper,
&stakingKeeper,
govRouter,
)

app.GovKeeper = gov.NewKeeper(app.cdc, keys[gov.StoreKey], app.subspaces[gov.ModuleName], app.SupplyKeeper,
&stakingKeeper, govRouter,
// Register custom modules
app.magpieKeeper = magpie.NewKeeper(
app.cdc,
keys[magpie.StoreKey],
)
app.postsKeeper = posts.NewKeeper(
app.cdc,
keys[posts.StoreKey],
)
app.profileKeeper = profile.NewKeeper(
app.cdc,
keys[profile.StoreKey],
)
app.reportsKeeper = reports.NewKeeper(
app.postsKeeper,
app.cdc,
keys[reports.StoreKey],
)

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

// Register custom modules
app.magpieKeeper = magpie.NewKeeper(app.cdc, keys[magpie.StoreKey])
app.postsKeeper = posts.NewKeeper(app.cdc, keys[posts.StoreKey])
app.profileKeeper = profile.NewKeeper(app.cdc, keys[profile.StoreKey])
app.reportsKeeper = reports.NewKeeper(app.postsKeeper, app.cdc, keys[reports.StoreKey])

// Create the module manager
// NOTE: Any module instantiated in the module manager that is later modified
// must be passed by reference here.
app.mm = module.NewManager(
genutil.NewAppModule(app.AccountKeeper, app.stakingKeeper, app.BaseApp.DeliverTx),
auth.NewAppModule(app.AccountKeeper),
bank.NewAppModule(app.BankKeeper, app.AccountKeeper),
crisis.NewAppModule(&app.CrisisKeeper),
gov.NewAppModule(app.GovKeeper, app.AccountKeeper, app.SupplyKeeper),
supply.NewAppModule(app.SupplyKeeper, app.AccountKeeper),
gov.NewAppModule(app.GovKeeper, app.AccountKeeper, app.SupplyKeeper),
slashing.NewAppModule(app.SlashingKeeper, app.AccountKeeper, app.stakingKeeper),
distr.NewAppModule(app.DistrKeeper, app.AccountKeeper, app.SupplyKeeper, app.stakingKeeper),
staking.NewAppModule(app.stakingKeeper, app.AccountKeeper, app.SupplyKeeper),
evidence.NewAppModule(app.evidenceKeeper),

// Custom modules
magpie.NewAppModule(app.magpieKeeper, app.AccountKeeper),
Expand All @@ -246,14 +310,17 @@ func NewDesmosApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest
app.mm.SetOrderBeginBlockers(distr.ModuleName, slashing.ModuleName)
app.mm.SetOrderEndBlockers(crisis.ModuleName, gov.ModuleName, staking.ModuleName)

// NOTE: The genutils module must occur after staking so that pools are
// properly initialized with tokens from genesis accounts.
app.mm.SetOrderInitGenesis(
auth.ModuleName, distr.ModuleName, staking.ModuleName, bank.ModuleName,
slashing.ModuleName, gov.ModuleName, supply.ModuleName, crisis.ModuleName, genutil.ModuleName,
auth.ModuleName, // loads all accounts - should run before any module with a module account
distr.ModuleName,
staking.ModuleName, bank.ModuleName, slashing.ModuleName,
gov.ModuleName, evidence.ModuleName,

// Custom modules
magpie.ModuleName, posts.ModuleName, profile.ModuleName, reports.ModuleName,
magpie.ModuleName, posts.ModuleName, profile.ModuleName, reports.ModuleName, // custom modules

supply.ModuleName, // calculates the total supply from account - should run after modules that modify accounts in genesis
crisis.ModuleName, // runs the invariants at genesis - should run after other modules
genutil.ModuleName, // genutils must occur after staking so that pools are properly initialized with tokens from genesis accounts.
)

app.mm.RegisterInvariants(&app.CrisisKeeper)
Expand All @@ -268,8 +335,9 @@ func NewDesmosApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest
bank.NewAppModule(app.BankKeeper, app.AccountKeeper),
supply.NewAppModule(app.SupplyKeeper, app.AccountKeeper),
gov.NewAppModule(app.GovKeeper, app.AccountKeeper, app.SupplyKeeper),
distr.NewAppModule(app.DistrKeeper, app.AccountKeeper, app.SupplyKeeper, app.stakingKeeper),
staking.NewAppModule(app.stakingKeeper, app.AccountKeeper, app.SupplyKeeper),
staking.NewAppModule(app.stakingKeeper, app.AccountKeeper, app.SupplyKeeper),
slashing.NewAppModule(app.SlashingKeeper, app.AccountKeeper, app.stakingKeeper),

// Custom modules
posts.NewAppModule(app.postsKeeper, app.AccountKeeper),
Expand Down
8 changes: 4 additions & 4 deletions app/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ import (
"path/filepath"
"testing"

"github.com/cosmos/cosmos-sdk/x/gov"

distr "github.com/cosmos/cosmos-sdk/x/distribution"
"github.com/cosmos/cosmos-sdk/x/gov"
"github.com/desmos-labs/desmos/x/magpie"
"github.com/desmos-labs/desmos/x/posts"
"github.com/desmos-labs/desmos/x/profile"
Expand Down Expand Up @@ -182,11 +181,12 @@ func TestAppImportExport(t *testing.T) {
[][]byte{
staking.UnbondingQueueKey, staking.RedelegationQueueKey, staking.ValidatorQueueKey,
}}, // ordering may change but it doesn't matter
{app.keys[supply.StoreKey], newApp.keys[supply.StoreKey], [][]byte{}},
{app.keys[distr.StoreKey], newApp.keys[distr.StoreKey], [][]byte{}},
{app.keys[slashing.StoreKey], newApp.keys[slashing.StoreKey], [][]byte{}},
{app.keys[distr.StoreKey], newApp.keys[distr.StoreKey], [][]byte{}},
{app.keys[supply.StoreKey], newApp.keys[supply.StoreKey], [][]byte{}},
{app.keys[params.StoreKey], newApp.keys[params.StoreKey], [][]byte{}},
{app.keys[gov.StoreKey], newApp.keys[gov.StoreKey], [][]byte{}},

{app.keys[magpie.StoreKey], newApp.keys[magpie.StoreKey], [][]byte{}},
{app.keys[posts.StoreKey], newApp.keys[posts.StoreKey], [][]byte{}},
{app.keys[profile.StoreKey], newApp.keys[profile.StoreKey], [][]byte{}},
Expand Down
6 changes: 3 additions & 3 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ module.exports = {
title: "Migrations",
collapsable: true,
children: [
["migrations/v0.3.0", "Migrate to version 0.3.0"],
["migrations/v0.5.x", "Migrate to version 0.5.x"],
["migrations/v0.6.x", "Migrate to version 0.6.x"],
["migrations/v0.3.0", "Migrate to version v0.3.0"],
["migrations/v0.5.x", "Migrate to version v0.5.x"],
["migrations/v0.6.x", "Migrate to version v0.6.x"],
]
}
],
Expand Down
4 changes: 2 additions & 2 deletions docs/migrations/v0.3.0.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Migrate to version 0.3.0
While updating you software from version `0.2.0` (or below) to `0.3.0`, you will need to perform some required actions.
# Migrate to version v0.3.0
While updating you software from version `v0.2.0` (or below) to `v0.3.0`, you will need to perform some required actions.

If you do not manage a validator node, please refer only to the ["*Users*" instructions](#users). However, if you do manage one please also read the ["*Validators*" instructions](#validators). Finally, if you are a developer refer also to the ["*Developers*" instructions](#developers)

Expand Down
6 changes: 3 additions & 3 deletions docs/migrations/v0.5.x.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Migrate to version 0.5.x
While updating you software from version `0.4.0` to `0.5.x`, if you run a validator you will need to perform some required actions.
# Migrate to version v0.5.x
While updating you software from version `v0.4.0` (or below) to `v0.5.x`, you will need to perform some required actions.

## Validators
Validators need to remember that they will have to execute the `migrate` command during a future chain upgrade. This will be also remembered inside the upgrade procedure guide.

A part from this, a small state change is required after executing the `migrate` command. Due to a bug back in `0.2.0`, the current state has three posts that have a parent id of a post which was created after them. To solve this problem, you need to search through the migrated `genesis.json` file and delete the posts having the following ids:
A part from this, a small state change is required after executing the `migrate` command. Due to a bug back in `v0.2.0`, the current state has three posts that have a parent id of a post which was created after them. To solve this problem, you need to search through the migrated `genesis.json` file and delete the posts having the following ids:

```
5167ad329eafd39296e0613c6af76f902668b19cbf6c9e1ba3a4da8ff3b74969
Expand Down
Loading

0 comments on commit faec7d3

Please sign in to comment.