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

Update genutil for sdk 50 #1925

Merged
merged 8 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ Ref: https://keepachangelog.com/en/1.0.0/
* Bump the SDK to `v0.50.5-pio-1` (from an earlier ephemeral version) [#1897](https://github.com/provenance-io/provenance/pull/1897).
* Removed `rewards` module [#1905](https://github.com/provenance-io/provenance/pull/1905).
* Remove unused navs [#1920](https://github.com/provenance-io/provenance/issues/1920).
* Update genutil for sdk 50 [#1760](https://github.com/provenance-io/provenance/issues/1760).
* Migrate module params from param space to module store.
* Attribute module param migration [#1927](https://github.com/provenance-io/provenance/pull/1927)
* Attribute module param migration [#1927](https://github.com/provenance-io/provenance/pull/1927).
Taztingo marked this conversation as resolved.
Show resolved Hide resolved

### Dependencies

Expand Down
7 changes: 4 additions & 3 deletions cmd/provenanced/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypesv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
Expand Down Expand Up @@ -227,10 +227,11 @@ func createAndExportGenesisFile(

// Set the gov deposit denom
{
// TODO[1760]: gov: Verify that these changes are okay and nothing else is needed.
moduleName := govtypes.ModuleName
var govGenState govtypesv1beta1.GenesisState
var govGenState govtypesv1.GenesisState
cdc.MustUnmarshalJSON(appGenState[moduleName], &govGenState)
govGenState.DepositParams.MinDeposit = sdk.NewCoins(sdk.NewInt64Coin(pioconfig.GetProvenanceConfig().BondDenom, minDeposit))
govGenState.Params.MinDeposit = sdk.NewCoins(sdk.NewInt64Coin(pioconfig.GetProvenanceConfig().BondDenom, minDeposit))
Taztingo marked this conversation as resolved.
Show resolved Hide resolved
appGenState[moduleName] = cdc.MustMarshalJSON(&govGenState)
}

Expand Down
15 changes: 13 additions & 2 deletions cmd/provenanced/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import (
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/cosmos/cosmos-sdk/x/crisis"
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"

// rosettacmd "github.com/cosmos/rosetta/cmd" // TODO[1760]: rosetta

Expand All @@ -73,6 +74,13 @@ func NewRootCmd(sealConfig bool) (*cobra.Command, params.EncodingConfig) {
}
defer os.RemoveAll(tempDir)

// These are added to prevent invalid address caching from tempApp.
sdk.SetAddrCacheEnabled(false)
defer sdk.SetAddrCacheEnabled(true)

// We initially set the config as testnet so commands that run before start work for testing such as gentx.
app.SetConfig(true, false)

tempApp := app.New(log.NewNopLogger(), dbm.NewMemDB(), nil, true, nil,
tempDir,
0,
Expand Down Expand Up @@ -189,8 +197,8 @@ func Execute(rootCmd *cobra.Command) error {
func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig, basicManager module.BasicManager) {
rootCmd.AddCommand(
InitCmd(basicManager),
// genutilcli.CollectGenTxsCmd(banktypes.GenesisBalancesIterator{}, app.DefaultNodeHome), // TODO[1760]: genutil
// genutilcli.GenTxCmd(app.ModuleBasics, encodingConfig.TxConfig, banktypes.GenesisBalancesIterator{}, app.DefaultNodeHome), // TODO[1760]: genutil
genutilcli.CollectGenTxsCmd(banktypes.GenesisBalancesIterator{}, app.DefaultNodeHome, genutiltypes.DefaultMessageValidator, encodingConfig.InterfaceRegistry.SigningContext().ValidatorAddressCodec()),
genutilcli.GenTxCmd(basicManager, encodingConfig.TxConfig, banktypes.GenesisBalancesIterator{}, app.DefaultNodeHome, encodingConfig.InterfaceRegistry.SigningContext().ValidatorAddressCodec()),
genutilcli.ValidateGenesisCmd(basicManager),
AddGenesisAccountCmd(app.DefaultNodeHome),
AddRootDomainAccountCmd(app.DefaultNodeHome),
Expand Down Expand Up @@ -365,6 +373,8 @@ func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts serverty
cast.ToUint32(appOpts.Get(server.FlagStateSyncSnapshotKeepRecent)),
)

chainID := cast.ToString(appOpts.Get(flags.FlagChainID))

return app.New(
logger, db, traceStore, true, skipUpgradeHeights,
cast.ToString(appOpts.Get(flags.FlagHome)),
Expand All @@ -381,6 +391,7 @@ func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts serverty
baseapp.SetSnapshot(snapshotStore, snapshotOptions),
baseapp.SetIAVLCacheSize(getIAVLCacheSize(appOpts)),
baseapp.SetIAVLDisableFastNode(cast.ToBool(appOpts.Get(server.FlagDisableIAVLFastNode))),
baseapp.SetChainID(chainID),
)
}

Expand Down
10 changes: 6 additions & 4 deletions cmd/provenanced/cmd/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypesv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

Expand Down Expand Up @@ -368,10 +368,12 @@ func initGenFiles(
appGenState[crisistypes.ModuleName] = clientCtx.Codec.MustMarshalJSON(&crisisGenState)

// Set the gov depost denom
var govGenState govtypesv1beta1.GenesisState
// TODO[1760]: gov: Verify that these changes are okay and nothing else is needed.
var govGenState govtypesv1.GenesisState
clientCtx.Codec.MustUnmarshalJSON(appGenState[govtypes.ModuleName], &govGenState)
govGenState.DepositParams.MinDeposit = sdk.NewCoins(sdk.NewInt64Coin(chainDenom, 10000000))
govGenState.VotingParams.VotingPeriod, _ = time.ParseDuration("360s")
govGenState.Params.MinDeposit = sdk.NewCoins(sdk.NewInt64Coin(chainDenom, 10000000))
votingPeriod, _ := time.ParseDuration("360s")
govGenState.Params.VotingPeriod = &votingPeriod
appGenState[govtypes.ModuleName] = clientCtx.Codec.MustMarshalJSON(&govGenState)

// Set the mint module parameters to stop inflation on the BondDenom.
Expand Down
Loading