Skip to content

Commit

Permalink
fix: snapshot commands panic if snapshot don't exists (#16138)
Browse files Browse the repository at this point in the history
(cherry picked from commit 92247cb)

# Conflicts:
#	CHANGELOG.md
  • Loading branch information
yihuang authored and mergify[bot] committed May 13, 2023
1 parent 10cc30f commit 49e11a3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,19 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Bug Fixes

<<<<<<< HEAD
* (store/iavl) [#15717](https://github.com/cosmos/cosmos-sdk/pull/15717) Upstream error on empty version (this change was present on all version but v0.46).
=======
* (x/staking) [#16043](https://github.com/cosmos/cosmos-sdk/pull/16043) Call `AfterUnbondingInitiated` hook for new unbonding entries only and fix `UnbondingDelegation` entries handling
* (types) [#16010](https://github.com/cosmos/cosmos-sdk/pull/16010) Let `module.CoreAppModuleBasicAdaptor` fallback to legacy genesis handling.
* (x/group) [#16017](https://github.com/cosmos/cosmos-sdk/pull/16017) Correctly apply account number in group v2 migration.
* (types) [#15691](https://github.com/cosmos/cosmos-sdk/pull/15691) Make `Coin.Validate()` check that `.Amount` is not nil.
* (x/auth) [#15059](https://github.com/cosmos/cosmos-sdk/pull/15059) `ante.CountSubKeys` returns 0 when passing a nil `Pubkey`.
* (x/capability) [#15030](https://github.com/cosmos/cosmos-sdk/pull/15030) Prevent `x/capability` from consuming `GasMeter` gas during `InitMemStore`
* (types/coin) [#14739](https://github.com/cosmos/cosmos-sdk/pull/14739) Deprecate the method `Coin.IsEqual` in favour of `Coin.Equal`. The difference between the two methods is that the first one results in a panic when denoms are not equal. This panic lead to unexpected behavior
* (x/crypto) [#15258](https://github.com/cosmos/cosmos-sdk/pull/15258) Write keyhash file with permissions 0600 instead of 0555.
* (cli) [#16138](https://github.com/cosmos/cosmos-sdk/pull/16138) Fix snapshot commands panic if snapshot don't exists.
>>>>>>> 92247cb0e (fix: snapshot commands panic if snapshot don't exists (#16138))
## [v0.46.12](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.12) - 2022-04-04

Expand Down
5 changes: 5 additions & 0 deletions client/snapshot/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package snapshot
import (
"archive/tar"
"compress/gzip"
"errors"
"fmt"
"io"
"os"
Expand Down Expand Up @@ -48,6 +49,10 @@ func DumpArchiveCmd() *cobra.Command {
return err
}

if snapshot == nil {
return errors.New("snapshot don't exists")
}

bz, err := snapshot.Marshal()
if err != nil {
return err
Expand Down
4 changes: 4 additions & 0 deletions snapshots/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,10 @@ func (m *Manager) RestoreLocalSnapshot(height uint64, format uint32) error {
return err
}

if snapshot == nil {
return fmt.Errorf("snapshot don't exists, height: %d, format: %d", height, format)
}

m.mtx.Lock()
defer m.mtx.Unlock()

Expand Down

0 comments on commit 49e11a3

Please sign in to comment.