-
Notifications
You must be signed in to change notification settings - Fork 188
feat: forest-cli snapshot export-diff #6074
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
Merged
Merged
Changes from 15 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
b3baae2
feat: forest-cli snapshot export-diff
hanabi1224 d001cf8
Merge branch 'main' into hm/snapshot-export-diff
hanabi1224 a6f3ecc
Merge branch 'main' into hm/snapshot-export-diff
hanabi1224 6e88043
unify chain export lock
hanabi1224 4867880
Merge remote-tracking branch 'origin/main' into hm/snapshot-export-diff
hanabi1224 4751d1d
CI test
hanabi1224 832d20f
fix shellcheck
hanabi1224 32194b1
move export-diff check to dedicated CI job
hanabi1224 c687b3a
Merge remote-tracking branch 'origin/main' into hm/snapshot-export-diff
hanabi1224 651572f
changelog
hanabi1224 066e1b2
fix typo
hanabi1224 a019230
fix shellcheck
hanabi1224 dcea4ab
resolve AI review comments
hanabi1224 791d55b
Update snapshot_cmd.rs
hanabi1224 049b324
fix build
hanabi1224 55d935f
Merge remote-tracking branch 'origin/main' into hm/snapshot-export-diff
hanabi1224 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| #!/usr/bin/env bash | ||
| # This script is checking the correctness of | ||
| # the diff snapshot export feature. | ||
| # It requires both the `forest` and `forest-cli` binaries to be in the PATH. | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| source "$(dirname "$0")/harness.sh" | ||
|
|
||
| forest_init "$@" | ||
|
|
||
| db_path=$($FOREST_TOOL_PATH db stats --chain calibnet | grep "Database path:" | cut -d':' -f2- | xargs) | ||
| snapshot=$(find "$db_path/car_db"/*.car.zst | tail -n 1) | ||
| snapshot_epoch=$(forest_query_epoch "$snapshot") | ||
|
|
||
| echo "Exporting diff snapshot @ $snapshot_epoch with forest-cli snapshot export-diff" | ||
| $FOREST_CLI_PATH snapshot export-diff --from "$snapshot_epoch" --to "$((snapshot_epoch - 900))" -d 900 -o diff1 | ||
|
|
||
| $FOREST_CLI_PATH shutdown --force | ||
|
|
||
| echo "Exporting diff snapshot @ $snapshot_epoch with forest-tool archive export" | ||
| $FOREST_TOOL_PATH archive export --epoch "$snapshot_epoch" --depth 900 --diff "$((snapshot_epoch - 900))" --diff-depth 900 -o diff2 "$snapshot" | ||
|
|
||
| echo "Comparing diff snapshots" | ||
| diff diff1 diff2 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Harden the script (pipefail, robust snapshot selection, and deterministic compare).
Current use of globbed
findand plaindiffis brittle. Addpipefail, fail fast if no snapshot, and pick the newest snapshot deterministically. Also prefer comparing normalized metadata to avoid false negatives from compression framing.Apply:
Optional: if strict byte-for-byte comparison is desired and deterministic, keep a second
diff diff1 diff2step.📝 Committable suggestion
🤖 Prompt for AI Agents