Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* [#1724](https://github.com/crypto-org-chain/cronos/pull/1724) Include the fix of nonce management in batch tx in ethermint.
* [#1748](https://github.com/crypto-org-chain/cronos/pull/1748) Query with GetCFWithTS to compare both timestamp and key to avoid run fixdata multiple times.
* (versiondb) [#1751](https://github.com/crypto-org-chain/cronos/pull/1751) Add missing Destroy for read options to properly hold and release options reference.
* [#1759](https://github.com/crypto-org-chain/cronos/pull/1759) Fix version mismatch happen occasionally.

### Improvements

Expand Down
33 changes: 26 additions & 7 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -1041,16 +1041,28 @@ func New(
}

if loadLatest {
if err := app.LoadLatestVersion(); err != nil {
tmos.Exit(err.Error())
var qmsVersion int64
if app.qms != nil {
qmsVersion = app.qms.LatestVersion()
}

if app.qms != nil {
v1 := app.qms.LatestVersion()
v2 := app.LastBlockHeight()
if v1 > 0 && v1 < v2 {
if qmsVersion == 0 {
if err := app.LoadLatestVersion(); err != nil {
tmos.Exit(err.Error())
}
} else {
// make sure iavl version is not ahead of versiondb version
app.SetStoreLoader(VersionStoreLoader(qmsVersion))

if err := app.LoadLatestVersion(); err != nil {
tmos.Exit(err.Error())
}

// still keep the check for safety
iavlVersion := app.LastBlockHeight()
if qmsVersion < iavlVersion {
// try to prevent gap being created in versiondb
tmos.Exit(fmt.Sprintf("versiondb version %d lag behind iavl version %d", v1, v2))
tmos.Exit(fmt.Sprintf("versiondb version %d lag behind iavl version %d", qmsVersion, iavlVersion))
}
}

Expand Down Expand Up @@ -1491,3 +1503,10 @@ func (app *App) CheckTx(req *abci.RequestCheckTx) (*abci.ResponseCheckTx, error)

return app.BaseApp.CheckTx(req)
}

// VersionStoreLoader will be used by default and loads the latest version
func VersionStoreLoader(version int64) baseapp.StoreLoader {
return func(ms storetypes.CommitMultiStore) error {
return ms.LoadVersion(version)
}
}
Loading