-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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 local snapshots management commands (backport #16067) #16102
feat: add local snapshots management commands (backport #16067) #16102
Conversation
Co-authored-by: Marko <marbar3778@yahoo.com> (cherry picked from commit c1ceb3b) # Conflicts: # CHANGELOG.md # go.mod # server/types/app.go # simapp/simd/cmd/root.go # simapp/simd/cmd/root_v2.go # snapshots/store.go
} | ||
|
||
path := args[0] | ||
fp, err := os.Open(path) |
Check failure
Code scanning / gosec
Potential file inclusion via variable
return err | ||
} | ||
|
||
fp, err := os.Create(output) |
Check failure
Code scanning / gosec
Potential file inclusion via variable
if err != nil { | ||
return err | ||
} | ||
defer fp.Close() |
Check failure
Code scanning / gosec
Deferring unsafe method "Close" on type "io.ReadCloser"
// The hash of the chunk is appended to the snapshot's metadata, | ||
// and the overall snapshot hash is updated with the chunk content too. | ||
func (s *Store) saveChunk(chunkBody io.ReadCloser, index uint32, snapshot *types.Snapshot, chunkHasher, snapshotHasher hash.Hash) error { | ||
defer chunkBody.Close() |
Check failure
Code scanning / gosec
Deferring unsafe method "Close" on type "io.ReadCloser"
if err != nil { | ||
return errors.Wrapf(err, "failed to create snapshot chunk file %q", path) | ||
} | ||
defer chunkFile.Close() |
Check failure
Code scanning / gosec
Deferring unsafe method "Close" on type "io.ReadCloser"
go func() { | ||
defer close(quitChan) | ||
|
||
savedSnapshot, err := snapshotStore.Save(snapshot.Height, snapshot.Format, chunks) | ||
if err != nil { | ||
fmt.Println("failed to save snapshot", err) | ||
return | ||
} | ||
quitChan <- savedSnapshot | ||
}() |
Check notice
Code scanning / CodeQL
Spawning a Go routine
"fmt" | ||
"io" | ||
"os" | ||
"reflect" |
Check notice
Code scanning / CodeQL
Sensitive package import
|
||
for i := uint32(0); i < snapshot.Chunks; i++ { | ||
path := snapshotStore.PathChunk(height, uint32(format), i) | ||
file, err := os.Open(path) |
Check failure
Code scanning / gosec
Potential file inclusion via variable
if err != nil { | ||
return fmt.Errorf("failed to open chunk file %s: %w", path, err) | ||
} | ||
defer file.Close() |
Check failure
Code scanning / gosec
Deferring unsafe method "Close" on type "io.ReadCloser"
@yihuang can we improve the restore command (from main)? If we try loading a non-existing snapshot, it panics with a nil pointer. |
sure |
…cosmos#16102) Co-authored-by: yihuang <huang@crypto.com> Co-authored-by: marbar3778 <marbar3778@yahoo.com> Co-authored-by: Julien Robert <julien@rbrt.fr>
…cosmos#16102) Co-authored-by: yihuang <huang@crypto.com> Co-authored-by: marbar3778 <marbar3778@yahoo.com> Co-authored-by: Julien Robert <julien@rbrt.fr>
This is an automatic backport of pull request #16067 done by Mergify.
Cherry-pick of c1ceb3b has failed:
To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/github/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally
Mergify commands and options
More conditions and actions can be found in the documentation.
You can also trigger Mergify actions by commenting on this pull request:
@Mergifyio refresh
will re-evaluate the rules@Mergifyio rebase
will rebase this PR on its base branch@Mergifyio update
will merge the base branch into this PR@Mergifyio backport <destination>
will backport this PR on<destination>
branchAdditionally, on Mergify dashboard you can:
Finally, you can contact us on https://mergify.com