Skip to content

Problem: memiavl don't support rollback#1091

Merged
yihuang merged 8 commits into
crypto-org-chain:mainfrom
yihuang:memiavl-rollback
Jul 3, 2023
Merged

Problem: memiavl don't support rollback#1091
yihuang merged 8 commits into
crypto-org-chain:mainfrom
yihuang:memiavl-rollback

Conversation

@yihuang

@yihuang yihuang commented Jul 3, 2023

Copy link
Copy Markdown
Contributor

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 devashishdxt and mmsqe and removed request for a team July 3, 2023 03:25
Comment thread CHANGELOG.md Outdated
Comment thread memiavl/db.go Outdated
Comment thread store/rootmulti/store.go
}

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

Check failure

Code scanning / gosec

Potential integer overflow by integer type conversion

Potential integer overflow by integer type conversion
Comment thread memiavl/multitree.go Fixed
Comment thread memiavl/multitree.go Fixed
Comment thread memiavl/multitree.go Fixed
Comment thread memiavl/multitree.go Fixed
Comment thread memiavl/multitree.go Fixed
Comment thread memiavl/multitree.go Fixed
Comment thread memiavl/db.go Fixed
Comment thread memiavl/db.go Fixed
Comment thread memiavl/db.go 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
@yihuang
yihuang force-pushed the memiavl-rollback branch from ec2fd49 to 2a8306b Compare July 3, 2023 03:38
Comment thread memiavl/import.go
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

Potential integer overflow by integer type conversion
Comment thread memiavl/export.go
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

Potential integer overflow by integer type conversion
Comment thread memiavl/db.go
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

Potential integer overflow by integer type conversion
Comment thread memiavl/db.go

// 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

Potential integer overflow by integer type conversion
Comment thread memiavl/db.go

// 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

Potential integer overflow by integer type conversion
@codecov

codecov Bot commented Jul 3, 2023

Copy link
Copy Markdown

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

Comment thread memiavl/db.go Outdated
Comment thread store/rootmulti/store.go Outdated
Comment thread store/rootmulti/store.go Outdated
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

3 participants