Skip to content
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

Problem: memiavl don't support rollback #1091

Merged
merged 8 commits into from
Jul 3, 2023

Conversation

yihuang
Copy link
Collaborator

@yihuang yihuang commented Jul 3, 2023

Closes: #1089

👮🏻👮🏻👮🏻 !!!! REFERENCE THE PROBLEM YOUR ARE SOLVING IN THE PR TITLE AND DESCRIBE YOUR SOLUTION HERE !!!! DO NOT FORGET !!!! 👮🏻👮🏻👮🏻

PR Checklist:

  • Have you read the CONTRIBUTING.md?
  • Does your PR follow the C4 patch requirements?
  • Have you rebased your work on top of the latest master?
  • Have you checked your code compiles? (make)
  • Have you included tests for any non-trivial functionality?
  • Have you checked your code passes the unit tests? (make test)
  • Have you checked your code formatting is correct? (go fmt)
  • Have you checked your basic code style is fine? (golangci-lint run)
  • If you added any dependencies, have you checked they do not contain any known vulnerabilities? (go list -json -m all | nancy sleuth)
  • If your changes affect the client infrastructure, have you run the integration test?
  • If your changes affect public APIs, does your PR follow the C4 evolution of public contracts?
  • If your code changes public APIs, have you incremented the crate version numbers and documented your changes in the CHANGELOG.md?
  • If you are contributing for the first time, please read the agreement in CONTRIBUTING.md now and add a comment to this pull request stating that your PR is in accordance with the Developer's Certificate of Origin.

Thank you for your code, it's appreciated! :)

@yihuang yihuang requested a review from a team as a code owner July 3, 2023 03:25
@yihuang yihuang requested review from mmsqe and devashishdxt and removed request for a team July 3, 2023 03:25
CHANGELOG.md Outdated Show resolved Hide resolved
memiavl/db.go Outdated Show resolved Hide resolved
}

opts := rs.opts
opts.TargetVersion = uint32(target)

Check failure

Code scanning / gosec

Potential integer overflow by integer type conversion Error

Potential integer overflow by integer type conversion
memiavl/multitree.go Fixed Show fixed Hide fixed
memiavl/multitree.go Fixed Show fixed Hide fixed
memiavl/multitree.go Fixed Show fixed Hide fixed
memiavl/multitree.go Fixed Show fixed Hide fixed
memiavl/multitree.go Fixed Show fixed Hide fixed
memiavl/multitree.go Fixed Show fixed Hide fixed
memiavl/db.go Fixed Show fixed Hide fixed
memiavl/db.go Fixed Show fixed Hide fixed
memiavl/db.go Fixed Show fixed Hide fixed
Closes: crypto-org-chain#1089

Update CHANGELOG.md

Signed-off-by: yihuang <huang@crypto.com>

Update memiavl/db.go

Signed-off-by: yihuang <huang@crypto.com>

revert int type changes
@@ -24,7 +24,7 @@
if height > math.MaxUint32 {
return snapshottypes.SnapshotItem{}, fmt.Errorf("version overflows uint32: %d", height)
}
snapshotDir := snapshotName(uint32(height))
snapshotDir := snapshotName(int64(height))

Check failure

Code scanning / gosec

Potential integer overflow by integer type conversion Error

Potential integer overflow by integer type conversion
@@ -46,7 +47,7 @@
if int64(version) > curVersion {
return fmt.Errorf("snapshot is not created yet: height: %d", version)
}
mtree, err = LoadMultiTree(snapshotPath(db.dir, version), true, 0)
mtree, err = LoadMultiTree(filepath.Join(db.dir, snapshotName(int64(version))), true, 0)

Check failure

Code scanning / gosec

Potential integer overflow by integer type conversion Error

Potential integer overflow by integer type conversion
found bool
)
if err := traverseSnapshots(root, false, func(version int64) (bool, error) {
if version <= int64(targetVersion) {

Check failure

Code scanning / gosec

Potential integer overflow by integer type conversion Error

Potential integer overflow by integer type conversion

// prune snapshots that's larger than the target version
if err := traverseSnapshots(dir, false, func(version int64) (bool, error) {
if version <= int64(opts.TargetVersion) {

Check failure

Code scanning / gosec

Potential integer overflow by integer type conversion Error

Potential integer overflow by integer type conversion

// truncate the WAL
opts.Logger.Info("truncate WAL from back, version: %d", opts.TargetVersion)
if err := wal.TruncateBack(walIndex(int64(opts.TargetVersion), mtree.initialVersion)); err != nil {

Check failure

Code scanning / gosec

Potential integer overflow by integer type conversion Error

Potential integer overflow by integer type conversion
@codecov
Copy link

codecov bot commented Jul 3, 2023

Codecov Report

Merging #1091 (2750120) into main (91fbcb4) will increase coverage by 0.36%.
The diff coverage is 50.45%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1091      +/-   ##
==========================================
+ Coverage   46.18%   46.55%   +0.36%     
==========================================
  Files          80       80              
  Lines        7195     7250      +55     
==========================================
+ Hits         3323     3375      +52     
+ Misses       3516     3514       -2     
- Partials      356      361       +5     
Impacted Files Coverage Δ
memiavl/export.go 57.95% <0.00%> (ø)
memiavl/db.go 56.41% <50.45%> (+1.10%) ⬆️
memiavl/import.go 65.28% <100.00%> (ø)

... and 1 file with indirect coverage changes

memiavl/db.go Outdated Show resolved Hide resolved
store/rootmulti/store.go Outdated Show resolved Hide resolved
store/rootmulti/store.go Outdated Show resolved Hide resolved
yihuang and others added 3 commits July 3, 2023 17:25
Co-authored-by: mmsqe <mavis@crypto.com>
Signed-off-by: yihuang <huang@crypto.com>
Co-authored-by: mmsqe <mavis@crypto.com>
Signed-off-by: yihuang <huang@crypto.com>
Co-authored-by: mmsqe <mavis@crypto.com>
Signed-off-by: yihuang <huang@crypto.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Problem: memiavl don't support rollback
2 participants