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

chore: sdk 50 basic module manager #607

Closed
wants to merge 8 commits into from
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
merged main
swelf19 committed Jul 2, 2024
commit e1b5c0dd70cdf1f534861b84c7c938772b42991c
8 changes: 4 additions & 4 deletions app/app.go
Original file line number Diff line number Diff line change
@@ -149,10 +149,10 @@ import (
tokenfactorykeeper "github.com/neutron-org/neutron/v4/x/tokenfactory/keeper"
tokenfactorytypes "github.com/neutron-org/neutron/v4/x/tokenfactory/types"

"github.com/cosmos/admin-module/x/adminmodule"
adminmodulecli "github.com/cosmos/admin-module/x/adminmodule/client/cli"
adminmodulekeeper "github.com/cosmos/admin-module/x/adminmodule/keeper"
adminmoduletypes "github.com/cosmos/admin-module/x/adminmodule/types"
"github.com/cosmos/admin-module/v2/x/adminmodule"
adminmodulecli "github.com/cosmos/admin-module/v2/x/adminmodule/client/cli"
adminmodulekeeper "github.com/cosmos/admin-module/v2/x/adminmodule/keeper"
adminmoduletypes "github.com/cosmos/admin-module/v2/x/adminmodule/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"

appparams "github.com/neutron-org/neutron/v4/app/params"
54 changes: 31 additions & 23 deletions app/genesis.go
Original file line number Diff line number Diff line change
@@ -2,6 +2,10 @@ package app

import (
"encoding/json"

"cosmossdk.io/math"

feemarkettypes "github.com/skip-mev/feemarket/x/feemarket/types"
)

var FeeDenom = "untrn"
@@ -17,30 +21,34 @@ type GenesisState map[string]json.RawMessage

// NewDefaultGenesisState generates the default state for the application.
func (app *App) NewDefaultGenesisState() GenesisState {
// This ugly hack is required to alter globalfee module genesis state
// because in current chain implementation staking module is absent which is required by globalfee module
// and we can't use default genesis state for globalfee module.
// If we do not alter globalfee module genesis state, then we will get panic during tests run.

genesisState := app.BasicModuleManager.DefaultGenesis(app.appCodec)
// globalFeeGenesisState := globalfeetypes.GenesisState{
// Params: globalfeetypes.Params{
// MinimumGasPrices: sdk.DecCoins{
// sdk.NewDecCoinFromDec(params.DefaultDenom, sdk.MustNewDecFromStr("0")),
// },
// BypassMinFeeMsgTypes: []string{
// sdk.MsgTypeURL(&ibcchanneltypes.MsgRecvPacket{}),
// sdk.MsgTypeURL(&ibcchanneltypes.MsgAcknowledgement{}),
// sdk.MsgTypeURL(&ibcclienttypes.MsgUpdateClient{}),
// },
// MaxTotalBypassMinFeeMsgGasUsage: globalfeetypes.DefaultmaxTotalBypassMinFeeMsgGasUsage,
// },
//}
// globalFeeGenesisStateBytes, err := json.Marshal(globalFeeGenesisState)
// if err != nil {
// panic("cannot marshal globalfee genesis state for tests")
//}
// genesisState["globalfee"] = globalFeeGenesisStateBytes

feemarketFeeGenesis := feemarkettypes.GenesisState{
Params: feemarkettypes.Params{
Alpha: math.LegacyOneDec(),
Beta: math.LegacyOneDec(),
Delta: math.LegacyOneDec(),
MinBaseGasPrice: math.LegacyMustNewDecFromStr("0.0025"),
MinLearningRate: math.LegacyMustNewDecFromStr("0.5"),
MaxLearningRate: math.LegacyMustNewDecFromStr("1.5"),
MaxBlockUtilization: 30_000_000,
Window: 1,
FeeDenom: FeeDenom,
Enabled: false,
DistributeFees: true,
},
State: feemarkettypes.State{
BaseGasPrice: math.LegacyMustNewDecFromStr("0.0025"),
LearningRate: math.LegacyOneDec(),
Window: []uint64{100},
Index: 0,
},
}
feemarketFeeGenesisStateBytes, err := json.Marshal(feemarketFeeGenesis)
if err != nil {
panic("cannot marshal feemarket genesis state for tests")
}
genesisState["feemarket"] = feemarketFeeGenesisStateBytes

return genesisState
}
9 changes: 8 additions & 1 deletion cmd/neutrond/root.go
Original file line number Diff line number Diff line change
@@ -114,7 +114,14 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) {
},
}

initRootCmd(rootCmd, encodingConfig, tempApp.BasicModuleManager)
initRootCmd(rootCmd, encodingConfig, tempApplication.BasicModuleManager)
initClientCtx, err := config.ReadDefaultValuesFromDefaultClientConfig(initClientCtx)
if err != nil {
panic(err)
}
if err := tempApplication.AutoCLIOpts(initClientCtx).EnhanceRootCommand(rootCmd); err != nil {
panic(err)
}

autoCliOpts := tempApplication.AutoCliOpts()
initClientCtx, _ = config.ReadFromClientConfig(initClientCtx)
8 changes: 5 additions & 3 deletions testutil/contractmanager/network/network.go
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ package network
import (
"fmt"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/neutron-org/neutron/v4/testutil"
"testing"
"time"

@@ -61,15 +62,17 @@ func DefaultConfig() network.Config {
// TODO: move to depinject
// we "pre"-instantiate the application for getting the injected/configured encoding configuration
// note, this is not necessary when using app wiring, as depinject can be directly used
chainID := "chain-" + tmrand.NewRand().Str(6)
tempHome := testutil.TestHomeDir(chainID)
tempApp := app.New(
log.NewNopLogger(),
memoryDB,
nil,
false,
map[int64]bool{},
app.DefaultNodeHome,
tempHome,
0,
sims.NewAppOptionsWithFlagHome(app.DefaultNodeHome),
sims.NewAppOptionsWithFlagHome(tempHome),
nil,
)
encoding := app.MakeEncodingConfig()
@@ -79,7 +82,6 @@ func DefaultConfig() network.Config {
tempApp.BasicModuleManager[stakingtypes.ModuleName] = staking.AppModule{}
tempApp.BasicModuleManager.RegisterInterfaces(encoding.InterfaceRegistry)

chainID := "chain-" + tmrand.NewRand().Str(6)
return network.Config{
Codec: encoding.Marshaler,
TxConfig: encoding.TxConfig,
8 changes: 5 additions & 3 deletions testutil/cron/network/network.go
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ package network

import (
"fmt"
"github.com/neutron-org/neutron/v4/testutil"
"testing"
"time"

@@ -69,15 +70,17 @@ func DefaultConfig() network.Config {
// TODO: move to depinject
// we "pre"-instantiate the application for getting the injected/configured encoding configuration
// note, this is not necessary when using app wiring, as depinject can be directly used
chainID := "chain-" + tmrand.NewRand().Str(6)
tempHome := testutil.TestHomeDir(chainID)
tempApp := app.New(
log.NewNopLogger(),
memoryDB,
nil,
false,
map[int64]bool{},
app.DefaultNodeHome,
tempHome,
0,
sims.NewAppOptionsWithFlagHome(app.DefaultNodeHome),
sims.NewAppOptionsWithFlagHome(tempHome),
nil,
)
encoding := app.MakeEncodingConfig()
@@ -87,7 +90,6 @@ func DefaultConfig() network.Config {
tempApp.BasicModuleManager[stakingtypes.ModuleName] = staking.AppModule{}
tempApp.BasicModuleManager.RegisterInterfaces(encoding.InterfaceRegistry)

chainID := "chain-" + tmrand.NewRand().Str(6)
return network.Config{
Codec: encoding.Marshaler,
TxConfig: encoding.TxConfig,
8 changes: 5 additions & 3 deletions testutil/interchainqueries/network/network.go
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ package network

import (
"fmt"
"github.com/neutron-org/neutron/v4/testutil"
"testing"
"time"

@@ -61,15 +62,17 @@ func DefaultConfig() network.Config {
// TODO: move to depinject
// we "pre"-instantiate the application for getting the injected/configured encoding configuration
// note, this is not necessary when using app wiring, as depinject can be directly used
chainID := "chain-" + tmrand.NewRand().Str(6)
tempHome := testutil.TestHomeDir(chainID)
tempApp := app.New(
log.NewNopLogger(),
memoryDB,
nil,
false,
map[int64]bool{},
app.DefaultNodeHome,
tempHome,
0,
sims.NewAppOptionsWithFlagHome(app.DefaultNodeHome),
sims.NewAppOptionsWithFlagHome(tempHome),
nil,
)
encoding := app.MakeEncodingConfig()
@@ -79,7 +82,6 @@ func DefaultConfig() network.Config {
tempApp.BasicModuleManager[stakingtypes.ModuleName] = staking.AppModule{}
tempApp.BasicModuleManager.RegisterInterfaces(encoding.InterfaceRegistry)

chainID := "chain-" + tmrand.NewRand().Str(6)
return network.Config{
Codec: encoding.Marshaler,
TxConfig: encoding.TxConfig,
8 changes: 5 additions & 3 deletions testutil/interchaintxs/network/network.go
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ package network

import (
"fmt"
"github.com/neutron-org/neutron/v4/testutil"
"testing"
"time"

@@ -62,15 +63,17 @@ func DefaultConfig() network.Config {
// TODO: move to depinject
// we "pre"-instantiate the application for getting the injected/configured encoding configuration
// note, this is not necessary when using app wiring, as depinject can be directly used
chainID := "chain-" + tmrand.NewRand().Str(6)
tempHome := testutil.TestHomeDir(chainID)
tempApp := app.New(
log.NewNopLogger(),
memoryDB,
nil,
false,
map[int64]bool{},
app.DefaultNodeHome,
tempHome,
0,
sims.NewAppOptionsWithFlagHome(app.DefaultNodeHome),
sims.NewAppOptionsWithFlagHome(tempHome),
nil,
)
encoding := app.MakeEncodingConfig()
@@ -80,7 +83,6 @@ func DefaultConfig() network.Config {
tempApp.BasicModuleManager[stakingtypes.ModuleName] = staking.AppModule{}
tempApp.BasicModuleManager.RegisterInterfaces(encoding.InterfaceRegistry)

chainID := "chain-" + tmrand.NewRand().Str(6)
return network.Config{
Codec: encoding.Marshaler,
TxConfig: encoding.TxConfig,
4 changes: 2 additions & 2 deletions testutil/test_helpers.go
Original file line number Diff line number Diff line change
@@ -285,7 +285,7 @@ func (suite *IBCConnectionTestSuite) SetupCCVChannels() {
}
}

func testHomeDir(chainID string) string {
func TestHomeDir(chainID string) string {
projectRoot := utils.RootDir()
return path.Join(projectRoot, ".testchains", chainID)
}
@@ -419,7 +419,7 @@ func SetupTestingApp(initValUpdates []cometbfttypes.ValidatorUpdate) func() (ibc
return func() (ibctesting.TestingApp, map[string]json.RawMessage) {
encoding := app.MakeEncodingConfig()
db := db2.NewMemDB()
homePath := testHomeDir("testchain-" + tmrand.NewRand().Str(6))
homePath := TestHomeDir("testchain-" + tmrand.NewRand().Str(6))
testApp := app.New(
log.NewNopLogger(),
db,
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.