Skip to content

Commit

Permalink
Update genutil for sdk 50 (#1925)
Browse files Browse the repository at this point in the history
* Update genutil for sdk 50.

* Add TODOs to verify changes and updated testnet.go based on rabbit ai feedback.

* Add SetChainID, and temporarily disable address caching for tempApp. Set initial config as testnet that will be overwritten by start.
  • Loading branch information
Taztingo authored Apr 16, 2024
1 parent 55a96da commit 8256904
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ 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)
* Metadata module param migration [#1932](https://github.com/provenance-io/provenance/pull/1932)
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))
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

0 comments on commit 8256904

Please sign in to comment.