[Storehouse] 010 Util convert v6 -> v7 checkpoint - #8583
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ce39b24 to
287bfbb
Compare
287bfbb to
a9c6645
Compare
a9c6645 to
ca39b1a
Compare
ca39b1a to
4d5c8bf
Compare
4d5c8bf to
91eb0a7
Compare
| ) error { | ||
| err := convertCheckpointV6ToV7Stream(inputDir, inputFileName, outputDir, outputFileName, logger, nWorker) | ||
| if err != nil { | ||
| cleanupErr := deleteCheckpointFiles(outputDir, outputFileName) |
There was a problem hiding this comment.
Re-running the conversion deletes the previously converted output. The "V7 output already exists" rejection from convertCheckpointV6ToV7Stream reaches this cleanup, and deleteCheckpointFiles removes every <outputFile>* file.
| streamFiles := filePaths(dir, streamName, subtrieLevel) | ||
| require.Equal(t, len(nonStreamFiles), len(streamFiles)) | ||
| for i, nf := range nonStreamFiles { | ||
| require.NoError(t, compareFiles(nf, streamFiles[i]), |
There was a problem hiding this comment.
compareFiles has a bug! It opens file1 twice (checkpoint_v6_test.go:451), so it can never fail. Fix the helper to os.Open(file2).
| if err != nil { | ||
| return 0, fmt.Errorf("could not read subtrie footer: %w", err) | ||
| } | ||
| if embeddedSum != expectedSum { |
There was a problem hiding this comment.
This only compares two stored checksums; the bytes actually read are never CRC-verified, so input corruption is copied into a V7 file that then carries a fresh valid checksum. The non-stream path verifies content CRC via readCheckpointSubTrie. Same applies to the top-trie path below.
| checksums := make([]uint32, subtrieCount) | ||
| for k := 0; k < subtrieCount; k++ { | ||
| r := <-results | ||
| if r.err != nil { |
There was a problem hiding this comment.
Returning on the first error leaves the other workers running. Their deferred Close renames temp files to final part files, possibly after the wrapper's deleteCheckpointFiles has run, leaving stray output that contradicts the godoc and blocks retries. Drain all subtrieCount results, then return the first error, aggregate the errors or/and build a stopping mechanism into the workers.
| go func() { | ||
| for i := range jobs { | ||
| sum, err := convertSubTrieFileV6ToV7Stream( | ||
| inputDir, inputFileName, outputDir, outputFileName, i, subtrieChecksums[i], logger) |
There was a problem hiding this comment.
subtrieChecksums is sized from the header while this loop hard-codes subtrieCount, so a checksum-valid header declaring fewer than 16 subtries panics in a worker goroutine. You could validate len(subtrieChecksums) == subtrieCount up front.
| flagNWorker, | ||
| ) | ||
| var err error | ||
| if flagStream { |
There was a problem hiding this comment.
stream could be a boolean input into ConvertCheckpointV6ToV7 so that you don't need to expose 2 methods with identical inputs.
91eb0a7 to
1c62fec
Compare
b82aac5 to
4528bb1
Compare
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
1 similar comment
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
4528bb1 to
7d6436a
Compare
7d6436a to
2708c79
Compare
2708c79 to
bb62e79
Compare
bb62e79 to
2adac61
Compare
e91fb18 to
3ec8d0a
Compare
3ec8d0a to
5863488
Compare
This comment has been minimized.
This comment has been minimized.
…l V7 conversion cleanup at bootstrap, logger and godoc fixes, and tests for the leaf-hash flag and V7 subtrie paths
Co-authored-by: zhangchiqing <811374+zhangchiqing@users.noreply.github.com>
5863488 to
f03b735
Compare
To bootstrap a payloadless EN, a v7 root checkpoint file is needed. This PR adds a util to convert a v6 root checkpoint into a v7 root checkpoint.
It adds two ways to convert: