-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
fix: add app version to params #11182
Changes from 6 commits
cdec534
d59a055
7f87350
1fead59
69b3599
e1c1a55
f892ab6
d56f5d6
ef4446f
1a40fb1
cf53846
93f981c
840d964
0533538
cc80298
a46b0f1
52b435e
7501871
e704983
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -34,7 +34,7 @@ type Keeper struct { | |||||
storeKey storetypes.StoreKey // key to access x/upgrade store | ||||||
cdc codec.BinaryCodec // App-wide binary codec | ||||||
upgradeHandlers map[string]types.UpgradeHandler // map of plan name to upgrade handler | ||||||
versionSetter xp.ProtocolVersionSetter // implements setting the protocol version field on BaseApp | ||||||
VersionSetter xp.ProtocolVersionSetter // implements setting the protocol version field on BaseApp | ||||||
amaury1093 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
downgradeVerified bool // tells if we've already sanity checked that this binary version isn't being used against an old state. | ||||||
} | ||||||
|
||||||
|
@@ -51,7 +51,7 @@ func NewKeeper(skipUpgradeHeights map[int64]bool, storeKey storetypes.StoreKey, | |||||
storeKey: storeKey, | ||||||
cdc: cdc, | ||||||
upgradeHandlers: map[string]types.UpgradeHandler{}, | ||||||
versionSetter: vs, | ||||||
VersionSetter: vs, | ||||||
} | ||||||
} | ||||||
|
||||||
|
@@ -70,8 +70,8 @@ func (k Keeper) setProtocolVersion(ctx sdk.Context, v uint64) { | |||||
store.Set([]byte{types.ProtocolVersionByte}, versionBytes) | ||||||
} | ||||||
|
||||||
// getProtocolVersion gets the protocol version from state | ||||||
func (k Keeper) getProtocolVersion(ctx sdk.Context) uint64 { | ||||||
// GetProtocolVersion gets the protocol version from state | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
func (k Keeper) GetProtocolVersion(ctx sdk.Context) uint64 { | ||||||
store := ctx.KVStore(k.storeKey) | ||||||
ok := store.Has([]byte{types.ProtocolVersionByte}) | ||||||
if ok { | ||||||
|
@@ -325,12 +325,12 @@ func (k Keeper) ApplyUpgrade(ctx sdk.Context, plan types.Plan) { | |||||
|
||||||
k.SetModuleVersionMap(ctx, updatedVM) | ||||||
|
||||||
// incremement the protocol version and set it in state and baseapp | ||||||
nextProtocolVersion := k.getProtocolVersion(ctx) + 1 | ||||||
// increment the protocol version and set it in state and baseapp | ||||||
nextProtocolVersion := k.GetProtocolVersion(ctx) + 1 | ||||||
k.setProtocolVersion(ctx, nextProtocolVersion) | ||||||
if k.versionSetter != nil { | ||||||
if k.VersionSetter != nil { | ||||||
// set protocol version on BaseApp | ||||||
k.versionSetter.SetProtocolVersion(nextProtocolVersion) | ||||||
k.VersionSetter.SetProtocolVersion(nextProtocolVersion) | ||||||
} | ||||||
|
||||||
// Must clear IBC state after upgrade is applied as it is stored separately from the upgrade plan. | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,7 +104,9 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { | |
} | ||
|
||
// InitGenesis is ignored, no sense in serializing future upgrades | ||
func (am AppModule) InitGenesis(_ sdk.Context, _ codec.JSONCodec, _ json.RawMessage) []abci.ValidatorUpdate { | ||
func (am AppModule) InitGenesis(ctx sdk.Context, _ codec.JSONCodec, _ json.RawMessage) []abci.ValidatorUpdate { | ||
version := am.keeper.GetProtocolVersion(ctx) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently x/upgrade doesn't have a genesis state. I think this line will always return 0. We should probably add a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so across genesis upgrades we don't retain app version? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm this may be wrong then, im not sure where to set this data for snapshot restoring. After we restore the snapshot we have to update the variable in BaseApp. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this doesn't work actually. I think the only way this works if its part of BaseApp, not upgrade module. It would be a circular dependency otherwise |
||
am.keeper.VersionSetter.SetProtocolVersion(version) | ||
return []abci.ValidatorUpdate{} | ||
} | ||
|
||
|
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.
Do we need a separate field? IMO we only need the AppVersion field
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.
version is used to represent the applications semantic software version, tendermint asks for both. In most cases I think its empty because it set via a flag.