-
Notifications
You must be signed in to change notification settings - Fork 0
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
Bump sdk v50 #5
base: main
Are you sure you want to change the base?
Bump sdk v50 #5
Conversation
@@ -14,12 +14,12 @@ message MultiStakingCoin { | |||
string denom = 1; | |||
string amount = 2 [ | |||
(cosmos_proto.scalar) = "cosmos.Int", | |||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", |
There was a problem hiding this comment.
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
@@ -70,7 +70,7 @@ message MultiStakingCoinInfo { | |||
string denom = 1; | |||
string bond_weight = 2 [ | |||
(cosmos_proto.scalar) = "cosmos.Dec", | |||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", |
There was a problem hiding this comment.
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
@@ -111,16 +115,13 @@ var ( | |||
auth.AppModuleBasic{}, | |||
genutil.AppModuleBasic{}, | |||
bank.AppModuleBasic{}, | |||
capability.AppModuleBasic{}, |
There was a problem hiding this comment.
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
@@ -161,6 +162,7 @@ type SimApp struct { | |||
legacyAmino *codec.LegacyAmino | |||
appCodec codec.Codec | |||
interfaceRegistry types.InterfaceRegistry | |||
txConfig client.TxConfig |
There was a problem hiding this comment.
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
authzkeeper.StoreKey, consensusparamtypes.StoreKey, | ||
) | ||
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) | ||
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) | ||
tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey) |
There was a problem hiding this comment.
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
@@ -254,47 +288,58 @@ func NewSimApp( | |||
// set the BaseApp's parameter store | |||
app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper( | |||
appCodec, | |||
keys[consensusparamtypes.StoreKey], | |||
runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]), |
There was a problem hiding this comment.
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
test/simapp/app.go
Outdated
logger, | ||
) | ||
|
||
enabledSignModes := append(tx.DefaultSignModes, sigtypes.SignMode_SIGN_MODE_TEXTUAL) |
There was a problem hiding this comment.
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
test/simapp/app.go
Outdated
|
||
app.BasicModuleManager = module.NewBasicManagerFromManager( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set up BasicModuleManager
@@ -520,6 +590,7 @@ func NewSimApp( | |||
|
|||
app.SetAnteHandler(anteHandler) | |||
app.SetInitChainer(app.InitChainer) | |||
app.SetPreBlocker(app.PreBlocker) |
There was a problem hiding this comment.
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
// BeginBlocker application updates every begin block | ||
func (app *SimApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock { |
There was a problem hiding this comment.
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
var genesisState GenesisState | ||
if err := json.Unmarshal(req.AppStateBytes, &genesisState); err != nil { | ||
if err := tmjson.Unmarshal(req.AppStateBytes, &genesisState); err != nil { | ||
panic(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check err for func
@@ -565,9 +649,9 @@ func (app *SimApp) LoadHeight(height int64) error { | |||
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename import
@@ -595,8 +679,13 @@ func (app *SimApp) RegisterTendermintService(clientCtx client.Context) { | |||
|
|||
// RegisterNodeService registers the node gRPC service on the provided | |||
// 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) { |
There was a problem hiding this comment.
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
) (servertypes.ExportedApp, error) { | ||
// as if they could withdraw from the start of the next block | ||
ctx := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()}) |
There was a problem hiding this comment.
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
@@ -29,7 +32,10 @@ func (app *SimApp) ExportAppStateAndValidators( | |||
app.prepForZeroHeightGenesis(ctx, jailAllowedAddrs) | |||
} | |||
|
|||
genState := app.mm.ExportGenesis(ctx, app.appCodec) |
There was a problem hiding this comment.
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
@@ -102,16 +125,33 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [] | |||
ctx = ctx.WithBlockHeight(0) | |||
|
|||
// reinitialize all validators | |||
app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check err for func
@@ -140,11 +144,11 @@ func AppStateRandomizedFn( | |||
// number of bonded accounts | |||
var initialStake, numInitiallyBonded int64 | |||
appParams.GetOrGenerate( | |||
cdc, sims.StakePerAccount, &initialStake, r, |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
|
||
// commit genesis changes |
There was a problem hiding this comment.
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
) | ||
|
||
// SetupSimulation creates the config, db (levelDB), temporary directory and logger for | ||
// 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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enable set up simulation
@@ -15,7 +16,8 @@ func (k Keeper) BeginBlocker(ctx sdk.Context) { | |||
} | |||
|
|||
// need a way to better name this func | |||
func GetUnbondingHeightsAndUnbondedAmounts(ctx sdk.Context, unbondingDelegation stakingtypes.UnbondingDelegation) map[int64]math.Int { |
There was a problem hiding this comment.
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
AppStateBytes: appState.AppState, | ||
}, | ||
) | ||
|
||
emptyApp.Commit() |
There was a problem hiding this comment.
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{ |
There was a problem hiding this comment.
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
} | ||
|
||
func (k Keeper) DequeueAllMatureUBDQueue(ctx sdk.Context, currTime time.Time) (matureUnbonds []stakingtypes.DVPair) { |
There was a problem hiding this comment.
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
@@ -689,10 +692,10 @@ func (suite *KeeperTestSuite) TestBeginRedelegate() { | |||
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) |
There was a problem hiding this comment.
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
func (AppModule) ConsensusVersion() uint64 { return 2 } | ||
func (AppModule) ConsensusVersion() uint64 { return 3 } | ||
|
||
// IsAppModule implements the appmodule.AppModule interface. |
There was a problem hiding this comment.
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 ( |
There was a problem hiding this comment.
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
x/multi-staking/module.go
Outdated
@@ -143,6 +150,9 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { | |||
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 { |
There was a problem hiding this comment.
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
func (am AppModule) IsAppModule() {} | ||
|
||
// IsOnePerModuleType implements the depinject.OnePerModuleType interface. | ||
func (am AppModule) IsOnePerModuleType() {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add interface func
legacyAmino := encodingConfig.Amino | ||
interfaceRegistry := encodingConfig.InterfaceRegistry | ||
legacyAmino := codec.NewLegacyAmino() | ||
interfaceRegistry, err := types.NewInterfaceRegistryWithOptions(types.InterfaceRegistryOptions{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set up encoding config
@@ -241,7 +275,7 @@ func NewSimApp( | |||
invCheckPeriod: invCheckPeriod, | |||
keys: keys, | |||
tkeys: tkeys, | |||
memKeys: memKeys, |
There was a problem hiding this comment.
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")), |
There was a problem hiding this comment.
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.
@@ -20,20 +20,20 @@ type App interface { | |||
LegacyAmino() *codec.LegacyAmino | |||
|
|||
// Application updates every begin block. | |||
BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock |
There was a problem hiding this comment.
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
@@ -42,7 +42,7 @@ func ModuleAccountInvariants(k Keeper) sdk.Invariant { | |||
moduleAccount := authtypes.NewModuleAddress(types.ModuleName) | |||
escrowBalances := k.bankKeeper.GetAllBalances(ctx, moduleAccount) | |||
|
|||
broken := !escrowBalances.IsEqual(totalLockCoinAmount) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
staking.AppModuleBasic{}, | ||
multistaking.AppModuleBasic{}, | ||
mint.AppModuleBasic{}, | ||
distr.AppModuleBasic{}, | ||
gov.NewAppModuleBasic( | ||
[]govclient.ProposalHandler{ | ||
paramsclient.ProposalHandler, | ||
upgradeclient.LegacyProposalHandler, |
There was a problem hiding this comment.
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
921f404
to
c19b60f
Compare
No description provided.