Skip to content

Bump sdk v50#5

Open
catShaark wants to merge 23 commits into
mainfrom
bump_sdk_v50
Open

Bump sdk v50#5
catShaark wants to merge 23 commits into
mainfrom
bump_sdk_v50

Conversation

@catShaark
Copy link
Copy Markdown

No description provided.

string denom = 1;
string amount = 2 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move to 50, we replace sdk.Int with math.Int

string denom = 1;
string bond_weight = 2 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sdk.Dec becomes math.LegacyDec

Comment thread test/simapp/app.go
auth.AppModuleBasic{},
genutil.AppModuleBasic{},
bank.AppModuleBasic{},
capability.AppModuleBasic{},
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(cosmos/cosmos-sdk#15344) Capability module was removed

Comment thread test/simapp/app.go
legacyAmino *codec.LegacyAmino
appCodec codec.Codec
interfaceRegistry types.InterfaceRegistry
txConfig client.TxConfig
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add txConfig and BasicModuleManager base to cosmos simapp

Comment thread test/simapp/app.go
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

References to types/store.go which contained aliases for store types have been remapped to point to appropriate store/types

Comment thread test/simapp/app.go
app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(
appCodec,
keys[consensusparamtypes.StoreKey],
runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]),
Copy link
Copy Markdown

@vietanh2k vietanh2k Oct 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the runtime.NewKVStoreService method to create a KVStoreService from a StoreKey

Comment thread test/simapp/app.go Outdated
logger,
)

enabledSignModes := append(tx.DefaultSignModes, sigtypes.SignMode_SIGN_MODE_TEXTUAL)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

must be added after setting the app's bank keeper when using (legacy) application wiring

Comment thread test/simapp/app.go Outdated

)

app.BasicModuleManager = module.NewBasicManagerFromManager(
Copy link
Copy Markdown

@vietanh2k vietanh2k Oct 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set up BasicModuleManager

Comment thread test/simapp/app.go

app.SetAnteHandler(anteHandler)
app.SetInitChainer(app.InitChainer)
app.SetPreBlocker(app.PreBlocker)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set a pre-blocker function for the app

Comment thread test/simapp/app.go
}

// BeginBlocker application updates every begin block
func (app *SimApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BeginBlock and EndBlock have changed their signature

Comment thread test/simapp/app.go
var genesisState GenesisState
if err := json.Unmarshal(req.AppStateBytes, &genesisState); err != nil {
if err := tmjson.Unmarshal(req.AppStateBytes, &genesisState); err != nil {
panic(err)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check err for func

Comment thread test/simapp/app.go
func (app *SimApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) {
clientCtx := apiSvr.ClientCtx
// Register new tx routes from grpc-gateway.
authtx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename import

Comment thread test/simapp/app.go
// application gRPC query router.
func (app *SimApp) RegisterNodeService(clientCtx client.Context) {
node.RegisterNodeService(clientCtx, app.GRPCQueryRouter())
func (app *SimApp) RegisterNodeService(clientCtx client.Context, cfg config.Config) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(cosmos/cosmos-sdk#15597) RegisterNodeService now requires a config parameter

Comment thread test/simapp/export.go
modulesToExport []string,
) (servertypes.ExportedApp, error) {
// as if they could withdraw from the start of the next block
ctx := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()})
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(cosmos/cosmos-sdk#16342) NewContext was renamed to NewContextLegacy

Comment thread test/simapp/export.go
app.prepForZeroHeightGenesis(ctx, jailAllowedAddrs)
}

genState := app.mm.ExportGenesis(ctx, app.appCodec)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ExportGenesis was changed to ExportGenesisForModules

Comment thread test/simapp/export.go
ctx = ctx.WithBlockHeight(0)

// reinitialize all validators
app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check err for func

Comment thread test/simapp/state.go
// number of bonded accounts
var initialStake, numInitiallyBonded int64
appParams.GetOrGenerate(
cdc, sims.StakePerAccount, &initialStake, r,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(cosmos/cosmos-sdk#16062) GetOrGenerate no longer requires a codec argument

)

// Setup initializes a new SimApp. A Nop logger is set in SimApp.
func Setup(isCheckTx bool) *SimApp {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove isCheckTx as it is not being used

panic(err)
}

// commit genesis changes
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Baseapp) BeginBlock and EndBlock are now internal to baseapp. For testing, user must call FinalizeBlock

Comment thread test/simapp/utils.go
// the simulation tests. If `FlagEnabledValue` is false it skips the current test.
// Returns error on an invalid db intantiation or temp dir creation.
func SetupSimulation(dirPrefix, dbName string) (simtypes.Config, dbm.DB, string, log.Logger, bool, error) {
if !FlagEnabledValue {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enable set up simulation

}

// need a way to better name this func
func GetUnbondingHeightsAndUnbondedAmounts(ctx sdk.Context, unbondingDelegation stakingtypes.UnbondingDelegation) map[int64]math.Int {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cosmos/cosmos-sdk#16324) NewKeeper now takes a KVStoreService instead of a StoreKey, and methods in the Keeper now take a context.Context instead of a sdk.Context

},
)

emptyApp.Commit()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

finalizeBlock 2 apps to fix the test export

editMsg := stakingtypes.NewMsgEditValidator(valAddr, stakingtypes.Description{
newRate := math.LegacyMustNewDecFromStr("0.03")
newMinSelfDelegation := math.NewInt(300)
editMsg := stakingtypes.NewMsgEditValidator(valAddr.String(), stakingtypes.Description{
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(cosmos/cosmos-sdk#17098) NewMsgCreateValidator, NewValidator, NewMsgCancelUnbondingDelegation, NewMsgUndelegate, NewMsgBeginRedelegate, NewMsgDelegate and NewMsgEditValidator takes a string instead of sdk.ValAddress or sdk.AccAddress

return sdkCtx.Logger().With("module", "x/"+types.ModuleName)
}

func (k Keeper) DequeueAllMatureUBDQueue(ctx sdk.Context, currTime time.Time) (matureUnbonds []stakingtypes.DVPair) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cosmos/cosmos-sdk#16324) NewKeeper now takes a KVStoreService instead of a StoreKey, and methods in the Keeper now take a context.Context instead of a sdk.Context

suite.Require().Equal(tc.expRate[0], lockRecord1.GetBondWeight())
suite.Require().Equal(tc.expLock[0], lockRecord1.LockedCoin.Amount)

delegation1, found := suite.app.StakingKeeper.GetDelegation(suite.ctx, delAddr, valAddr1)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now returns an error instead of a found bool

Comment thread x/multi-staking/module.go
func (AppModule) ConsensusVersion() uint64 { return 2 }
func (AppModule) ConsensusVersion() uint64 { return 3 }

// IsAppModule implements the appmodule.AppModule interface.
Copy link
Copy Markdown

@vietanh2k vietanh2k Oct 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

increase ConsensusVersion

)

// Simulation parameter constants
const (
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create RandomizedGenState for module multi-staking

Comment thread x/multi-staking/module.go Outdated
if err := cfg.RegisterMigration(multistakingtypes.ModuleName, 1, m.Migrate1to2); err != nil {
panic(fmt.Sprintf("failed to migrate x/%s from version 1 to 2: %v", stakingtypes.ModuleName, err))
}
if err := cfg.RegisterMigration(multistakingtypes.ModuleName, 2, m.Migrate2to3); err != nil {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

upgrade handler from v0.47 to v0.50

Comment thread x/multi-staking/module.go
func (am AppModule) IsAppModule() {}

// IsOnePerModuleType implements the depinject.OnePerModuleType interface.
func (am AppModule) IsOnePerModuleType() {}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add interface func

Comment thread test/simapp/app.go
legacyAmino := encodingConfig.Amino
interfaceRegistry := encodingConfig.InterfaceRegistry
legacyAmino := codec.NewLegacyAmino()
interfaceRegistry, err := types.NewInterfaceRegistryWithOptions(types.InterfaceRegistryOptions{
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set up encoding config

Comment thread test/simapp/app.go
invCheckPeriod: invCheckPeriod,
keys: keys,
tkeys: tkeys,
memKeys: memKeys,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove as it is not being used

genutilcli.CollectGenTxsCmd(banktypes.GenesisBalancesIterator{}, simapp.DefaultNodeHome, genutiltypes.DefaultMessageValidator),
genutilcli.MigrateGenesisCmd(),
genutilcli.GenTxCmd(simapp.ModuleBasics, encodingConfig.TxConfig, banktypes.GenesisBalancesIterator{}, simapp.DefaultNodeHome),
genutilcli.CollectGenTxsCmd(banktypes.GenesisBalancesIterator{}, simapp.DefaultNodeHome, genutiltypes.DefaultMessageValidator, addresscodec.NewBech32Codec("cosmos")),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(cosmos/cosmos-sdk#15567) CollectGenTxsCmd & GenTxCmd takes a address.Codec to be able to decode addresses.

Comment thread test/simapp/types.go
LegacyAmino() *codec.LegacyAmino

// Application updates every begin block.
BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BeginBlock and EndBlock have changed their signature

moduleAccount := authtypes.NewModuleAddress(types.ModuleName)
escrowBalances := k.bankKeeper.GetAllBalances(ctx, moduleAccount)

broken := !escrowBalances.IsEqual(totalLockCoinAmount)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(cosmos/cosmos-sdk#14739) Deprecate the method Coin.IsEqual in favour of Coin.Equal.


app.BeginBlock(abci.RequestBeginBlock{Header: newHeader})

suite.ctx = app.NewContext(false, newHeader)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update base on cosmos sdk NextBlock

Comment thread test/simapp/app.go
gov.NewAppModuleBasic(
[]govclient.ProposalHandler{
paramsclient.ProposalHandler,
upgradeclient.LegacyProposalHandler,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(cosmos/cosmos-sdk#14880) use gov v1 proposals in upgrade cli

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants