Skip to content

Commit

Permalink
test custom inflation func
Browse files Browse the repository at this point in the history
review comments

review comments

rebase cosmos-sdk patches

review comment

address comments
  • Loading branch information
arijitAD committed Nov 1, 2021
1 parent 9dbc53f commit c65f9fe
Show file tree
Hide file tree
Showing 20 changed files with 1,466 additions and 174 deletions.
16 changes: 14 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"io"
"net/http"
"os"
"path/filepath"

bam "github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
Expand Down Expand Up @@ -55,9 +56,12 @@ import (
ibc "github.com/cosmos/ibc-go/modules/core"
porttypes "github.com/cosmos/ibc-go/modules/core/05-port/types"
"github.com/gorilla/mux"
"github.com/ovrclk/akash/x/inflation"
inflationtypes "github.com/ovrclk/akash/x/inflation/types/v1beta2"
"github.com/rakyll/statik/fs"
"github.com/spf13/cast"
tmjson "github.com/tendermint/tendermint/libs/json"
tmtypes "github.com/tendermint/tendermint/types"

"github.com/cosmos/cosmos-sdk/x/params"
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
Expand Down Expand Up @@ -155,6 +159,7 @@ type AkashApp struct {
provider pkeeper.IKeeper
audit audit.Keeper
cert cert.Keeper
inflation inflation.Keeper
}

mm *module.Manager
Expand All @@ -173,6 +178,12 @@ func NewApp(
logger log.Logger, db dbm.DB, tio io.Writer, loadLatest bool, invCheckPeriod uint, skipUpgradeHeights map[int64]bool,
homePath string, appOpts servertypes.AppOptions, options ...func(*bam.BaseApp),
) *AkashApp {
// find out the genesis time, to be used later in inflation calculation
if genDoc, err := tmtypes.GenesisDocFromFile(filepath.Join(homePath, "config/genesis.json")); err != nil {
panic(err)
} else {
inflationtypes.GenesisTime = genDoc.GenesisTime
}

// TODO: Remove cdc in favor of appCodec once all modules are migrated.
encodingConfig := MakeEncodingConfig()
Expand Down Expand Up @@ -334,6 +345,7 @@ func NewApp(
app.keeper.evidence = *evidenceKeeper

app.setAkashKeepers()
inflationtypes.InflationParamSubspace = app.GetSubspace(inflation.ModuleName)

// NOTE: we may consider parsing `appOpts` inside module constructors. For the moment
// we prefer to be more strict in what arguments the modules expect.
Expand All @@ -349,7 +361,7 @@ func NewApp(
capability.NewAppModule(appCodec, *app.keeper.cap),
crisis.NewAppModule(&app.keeper.crisis, skipGenesisInvariants),
gov.NewAppModule(appCodec, app.keeper.gov, app.keeper.acct, app.keeper.bank),
mint.NewAppModule(appCodec, app.keeper.mint, app.keeper.acct),
mint.NewAppModule(appCodec, app.keeper.mint, app.keeper.acct, inflationtypes.InflationCalculator),
slashing.NewAppModule(appCodec, app.keeper.slashing, app.keeper.acct, app.keeper.bank, app.keeper.staking),
distr.NewAppModule(appCodec, app.keeper.distr, app.keeper.acct, app.keeper.bank, app.keeper.staking),
staking.NewAppModule(appCodec, app.keeper.staking, app.keeper.acct, app.keeper.bank),
Expand Down Expand Up @@ -416,7 +428,7 @@ func NewApp(
bank.NewAppModule(appCodec, app.keeper.bank, app.keeper.acct),
capability.NewAppModule(appCodec, *app.keeper.cap),
gov.NewAppModule(appCodec, app.keeper.gov, app.keeper.acct, app.keeper.bank),
mint.NewAppModule(appCodec, app.keeper.mint, app.keeper.acct),
mint.NewAppModule(appCodec, app.keeper.mint, app.keeper.acct, inflationtypes.InflationCalculator),
staking.NewAppModule(appCodec, app.keeper.staking, app.keeper.acct, app.keeper.bank),
distr.NewAppModule(appCodec, app.keeper.distr, app.keeper.acct, app.keeper.bank, app.keeper.staking),
slashing.NewAppModule(appCodec, app.keeper.slashing, app.keeper.acct, app.keeper.bank, app.keeper.staking),
Expand Down
16 changes: 16 additions & 0 deletions app/app_configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/ovrclk/akash/x/deployment"
"github.com/ovrclk/akash/x/escrow"
ekeeper "github.com/ovrclk/akash/x/escrow/keeper"
"github.com/ovrclk/akash/x/inflation"
"github.com/ovrclk/akash/x/market"
mhooks "github.com/ovrclk/akash/x/market/hooks"
"github.com/ovrclk/akash/x/provider"
Expand All @@ -22,6 +23,7 @@ func akashModuleBasics() []module.AppModuleBasic {
provider.AppModuleBasic{},
audit.AppModuleBasic{},
cert.AppModuleBasic{},
inflation.AppModuleBasic{},
}
}

Expand All @@ -33,12 +35,14 @@ func akashKVStoreKeys() []string {
provider.StoreKey,
audit.StoreKey,
cert.StoreKey,
inflation.StoreKey,
}
}

func akashSubspaces(k paramskeeper.Keeper) paramskeeper.Keeper {
k.Subspace(deployment.ModuleName)
k.Subspace(market.ModuleName)
k.Subspace(inflation.ModuleName)
return k
}

Expand Down Expand Up @@ -83,6 +87,12 @@ func (app *AkashApp) setAkashKeepers() {
app.appCodec,
app.keys[cert.StoreKey],
)

app.keeper.inflation = inflation.NewKeeper(
app.appCodec,
app.keys[inflation.StoreKey],
app.GetSubspace(inflation.ModuleName),
)
}

func (app *AkashApp) akashAppModules() []module.AppModule {
Expand Down Expand Up @@ -128,6 +138,11 @@ func (app *AkashApp) akashAppModules() []module.AppModule {
app.appCodec,
app.keeper.cert,
),

inflation.NewAppModule(
app.appCodec,
app.keeper.inflation,
),
}
}

Expand All @@ -144,6 +159,7 @@ func (app *AkashApp) akashInitGenesisOrder() []string {
deployment.ModuleName,
provider.ModuleName,
market.ModuleName,
inflation.ModuleName,
}
}

Expand Down
8 changes: 5 additions & 3 deletions client/docs/statik/statik.go

Large diffs are not rendered by default.

Loading

0 comments on commit c65f9fe

Please sign in to comment.