forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 34
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
feat!: add app version to param store #360
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
51f967a
add app version to param store
cmwaters e975a7d
register VersionParams
cmwaters 4c897c6
build(deps): bump github.com/celestiaorg/nmt from 0.19.0 to 0.20.0 (#…
dependabot[bot] 17b9ced
add conditional statement for setting the app version in the param store
cmwaters f6b3cfd
Merge branch 'main' into cal/perist-app-version
cmwaters fb6756e
resolve merge conflicts
cmwaters 0dae054
downgrade to 1.19
cmwaters af6d671
Info queries the param store
cmwaters 8e47396
go fmt
cmwaters 3498b4f
fix build issues
cmwaters ecc0df9
only persist app version if it is greater than 1
cmwaters 2f33ed2
go fmt
cmwaters b343c7d
fix that one line that seems to break everything
cmwaters File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,7 +53,6 @@ type BaseApp struct { // nolint: maligned | |
postHandler sdk.AnteHandler // post handler, optional, e.g. for tips | ||
|
||
appStore | ||
baseappVersions | ||
peerFilters | ||
snapshotData | ||
abciData | ||
|
@@ -98,6 +97,13 @@ type BaseApp struct { // nolint: maligned | |
// ResponseCommit.RetainHeight. | ||
minRetainBlocks uint64 | ||
|
||
// application's version string | ||
version string | ||
|
||
// application's protocol version that increments on every upgrade | ||
// if BaseApp is passed to the upgrade keeper's NewKeeper method. | ||
appVersion uint64 | ||
Comment on lines
+100
to
+105
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. [not blocking] can these two include an example to help further differentiate them? If |
||
|
||
// recovery handler for app.runTx method | ||
runTxRecoveryMiddleware recoveryMiddleware | ||
|
||
|
@@ -145,15 +151,6 @@ type abciData struct { | |
voteInfos []abci.VoteInfo | ||
} | ||
|
||
type baseappVersions struct { | ||
// application's version string | ||
version string | ||
|
||
// application's protocol version that increments on every upgrade | ||
// if BaseApp is passed to the upgrade keeper's NewKeeper method. | ||
appVersion uint64 | ||
} | ||
|
||
// should really get handled in some db struct | ||
// which then has a sub-item, persistence fields | ||
type snapshotData struct { | ||
|
@@ -206,7 +203,14 @@ func (app *BaseApp) Name() string { | |
} | ||
|
||
// AppVersion returns the application's protocol version. | ||
func (app *BaseApp) AppVersion() uint64 { | ||
func (app *BaseApp) AppVersion(ctx sdk.Context) uint64 { | ||
if app.appVersion == 0 && app.paramStore.Has(ctx, ParamStoreKeyVersionParams) { | ||
var vp tmproto.VersionParams | ||
|
||
app.paramStore.Get(ctx, ParamStoreKeyVersionParams, &vp) | ||
// set the app version | ||
app.appVersion = vp.AppVersion | ||
} | ||
return app.appVersion | ||
} | ||
|
||
|
@@ -482,7 +486,12 @@ func (app *BaseApp) GetConsensusParams(ctx sdk.Context) *abci.ConsensusParams { | |
cp.Validator = &vp | ||
} | ||
|
||
cp.Version = &tmproto.VersionParams{AppVersion: app.appVersion} | ||
if app.paramStore.Has(ctx, ParamStoreKeyVersionParams) { | ||
var vp tmproto.VersionParams | ||
|
||
app.paramStore.Get(ctx, ParamStoreKeyVersionParams, &vp) | ||
cp.Version = &vp | ||
} | ||
|
||
return cp | ||
} | ||
|
@@ -507,8 +516,10 @@ func (app *BaseApp) StoreConsensusParams(ctx sdk.Context, cp *abci.ConsensusPara | |
app.paramStore.Set(ctx, ParamStoreKeyBlockParams, cp.Block) | ||
app.paramStore.Set(ctx, ParamStoreKeyEvidenceParams, cp.Evidence) | ||
app.paramStore.Set(ctx, ParamStoreKeyValidatorParams, cp.Validator) | ||
// We're explicitly not storing the Tendermint app_version in the param store. It's | ||
// stored instead in the x/upgrade store, with its own bump logic. | ||
// NOTE: we only persist the app version from v2 onwards | ||
if cp.Version != nil && cp.Version.AppVersion >= 2 { | ||
app.paramStore.Set(ctx, ParamStoreKeyVersionParams, cp.Version) | ||
} | ||
} | ||
|
||
// getMaximumBlockGas gets the maximum gas from the consensus params. It panics | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
package exported | ||
|
||
import sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
// ProtocolVersionSetter defines the interface fulfilled by BaseApp | ||
// which allows setting it's appVersion field. | ||
type ProtocolVersionSetter interface { | ||
SetProtocolVersion(uint64) | ||
SetAppVersion(sdk.Context, uint64) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
[question] where or how does this "set" the app version? The invoked function returns the app version but I don't know what "set" is referring to here.
cosmos-sdk/baseapp/baseapp.go
Lines 208 to 211 in 4c897c6