Skip to content

Commit

Permalink
Problem: panic when store not exists in historical version
Browse files Browse the repository at this point in the history
Solution:
- make a dummy store, so client get empty data instead of panic on nil pointer
  • Loading branch information
yihuang committed May 16, 2024
1 parent d00edcb commit c9d4092
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
## [Unreleased]

* (x/staking) Fix a possible bypass of delagator slashing: [GHSA-86h5-xcpx-cfqc](https://github.com/cosmos/cosmos-sdk/security/advisories/GHSA-86h5-xcpx-cfqc)
* (store) Fix a nil pointer panic when query historical state where a new store don't exist.

## [v0.47.11](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.11) - 2024-04-22

Expand Down
5 changes: 5 additions & 0 deletions store/rootmulti/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,11 @@ func (rs *Store) CacheMultiStoreWithVersion(version int64) (types.CacheMultiStor
}
}

if cacheStore == nil {

Check failure on line 542 in store/rootmulti/store.go

View workflow job for this annotation

GitHub Actions / golangci-lint

SA4023: this comparison is never true (staticcheck)
// when loading a historical version, the store might not exists yet.
cacheStore = dbadapter.Store{DB: dbm.NewMemDB()}
}

default:
cacheStore = store
}
Expand Down

0 comments on commit c9d4092

Please sign in to comment.