Skip to content

Add support for Cid-indexed data in forest-tool api generate-test-snapshot #5597

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

Open
wants to merge 23 commits into
base: main
Choose a base branch
from

Conversation

elmattic
Copy link
Contributor

@elmattic elmattic commented Apr 23, 2025

Summary of changes

Changes introduced in this pull request:

  • Add support for writing Cid-indexed data in forest-tool api generate-test-snapshot
  • Avoid CDN caching in rpc_regression_tests
  • Add shell script to easily upload rcpsnap files to DO
./scripts/tests/upload_rcpsnaps.sh temp
temp/filecoin_chaingetevents_1745400136273439.rpcsnap.json : 74.99%   (  3.46 MiB =>   2.59 MiB, temp/filecoin_chaingetevents_1745400136273439.rpcsnap.json.zst) 
✅ Uploaded: temp/filecoin_chaingetevents_1745400136273439.rpcsnap.json.zst
temp/filecoin_chaingetevents_1745400136273611.rpcsnap.json : 74.81%   (  3.54 MiB =>   2.65 MiB, temp/filecoin_chaingetevents_1745400136273611.rpcsnap.json.zst) 
✅ Uploaded: temp/filecoin_chaingetevents_1745400136273611.rpcsnap.json.zst
temp/filecoin_chaingetevents_1745400136273670.rpcsnap.json : 74.42%   (  3.64 MiB =>   2.71 MiB, temp/filecoin_chaingetevents_1745400136273670.rpcsnap.json.zst) 
✅ Uploaded: temp/filecoin_chaingetevents_1745400136273670.rpcsnap.json.zst
temp/filecoin_chaingetevents_1745400136273739.rpcsnap.json : 74.10%   (  3.79 MiB =>   2.81 MiB, temp/filecoin_chaingetevents_1745400136273739.rpcsnap.json.zst) 
✅ Uploaded: temp/filecoin_chaingetevents_1745400136273739.rpcsnap.json.zst
temp/filecoin_chaingetevents_1745400136273790.rpcsnap.json : 73.66%   (  3.95 MiB =>   2.91 MiB, temp/filecoin_chaingetevents_1745400136273790.rpcsnap.json.zst) 
✅ Uploaded: temp/filecoin_chaingetevents_1745400136273790.rpcsnap.json.zst
temp/filecoin_chaingetevents_1745400136273834.rpcsnap.json : 73.08%   (  4.04 MiB =>   2.95 MiB, temp/filecoin_chaingetevents_1745400136273834.rpcsnap.json.zst) 
✅ Uploaded: temp/filecoin_chaingetevents_1745400136273834.rpcsnap.json.zst
temp/filecoin_chaingetevents_1745400136273881.rpcsnap.json : 73.12%   (  4.04 MiB =>   2.95 MiB, temp/filecoin_chaingetevents_1745400136273881.rpcsnap.json.zst) 
✅ Uploaded: temp/filecoin_chaingetevents_1745400136273881.rpcsnap.json.zst
temp/filecoin_chaingetevents_1745400136273923.rpcsnap.json : 72.69%   (  4.12 MiB =>   2.99 MiB, temp/filecoin_chaingetevents_1745400136273923.rpcsnap.json.zst) 
✅ Uploaded: temp/filecoin_chaingetevents_1745400136273923.rpcsnap.json.zst
temp/filecoin_chaingetevents_1745400136273969.rpcsnap.json : 72.24%   (  4.26 MiB =>   3.08 MiB, temp/filecoin_chaingetevents_1745400136273969.rpcsnap.json.zst) 
✅ Uploaded: temp/filecoin_chaingetevents_1745400136273969.rpcsnap.json.zst
temp/filecoin_chaingetevents_1745400136274014.rpcsnap.json : 72.17%   (  4.26 MiB =>   3.07 MiB, temp/filecoin_chaingetevents_1745400136274014.rpcsnap.json.zst) 
✅ Uploaded: temp/filecoin_chaingetevents_1745400136274014.rpcsnap.json.zst
🧪 Do you want to run 'cargo test --lib -- --test rpc_regression_tests --nocapture'? [y/N] y
▶ Running tests...
   Compiling forest-filecoin v0.26.0 (/Users/guillaume/Code/dark-forest)
    Finished `test` profile [unoptimized] target(s) in 29.54s
     Running unittests src/lib.rs (target/debug/deps/forest-852e1bcfd35dd13c)

running 2 tests
test tool::subcommands::api_cmd::test_snapshot::tests::rpc_regression_tests_print_uncovered ... ok
Testing filecoin_beacongetentry_1741270283524366.rpcsnap.json.zst ...  succeeded, took 682ms 813us 333ns.
Testing filecoin_chaingetblock_1736937164811210.rpcsnap.json.zst ...  succeeded, took 7ms 796us 458ns.
Testing filecoin_chaingetblockmessages_1736937164799678.rpcsnap.json.zst ...  succeeded, took 5ms 803us 542ns.
Testing filecoin_chaingetevents_1745400136273439.rpcsnap.json.zst ...  succeeded, took 22s 971ms 800us 83ns.
Testing filecoin_chaingetevents_1745400136273670.rpcsnap.json.zst ...  succeeded, took 83ms 517us.
Testing filecoin_chaingetevents_1745400136273739.rpcsnap.json.zst ...  succeeded, took 85ms 146us 834ns.
Testing filecoin_chaingetevents_1745400136273790.rpcsnap.json.zst ...  succeeded, took 103ms 65us 792ns.
Testing filecoin_chaingetevents_1745400136273611.rpcsnap.json.zst ...  succeeded, took 72ms 524us 792ns.
Testing filecoin_chaingetevents_1745400136273881.rpcsnap.json.zst ...  succeeded, took 93ms 428us 583ns.
Testing filecoin_chaingetevents_1745400136273923.rpcsnap.json.zst ...  succeeded, took 74ms 324us 833ns.
Testing filecoin_chaingetgenesis_1736937286915866.rpcsnap.json.zst ...  succeeded, took 6ms 605us 667ns.
Testing filecoin_chaingetmessage_1741270616352800.rpcsnap.json.zst ...  succeeded, took 7ms 997us.
Testing filecoin_chaingetevents_1745400136274014.rpcsnap.json.zst ...  succeeded, took 111ms 873us 625ns.
Testing filecoin_chaingetmessagesintipset_1741270616353560.rpcsnap.json.zst ...  succeeded, took 3ms 932us
...

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 517 filtered out; finished in 121.97s

Reference issue to close (if applicable)

Closes #5585

Other information and links

Change checklist

  • I have performed a self-review of my own code,
  • I have made corresponding changes to the documentation. All new code adheres to the team's documentation standards,
  • I have added tests that prove my fix is effective or that my feature works (if possible),
  • I have made sure the CHANGELOG is up-to-date. All user-facing changes should be reflected in this document.

@elmattic elmattic changed the title Add support for filecoin data Add support for Cid-indexed data in forest-tool api generate-test-snapshot Apr 28, 2025
@elmattic elmattic marked this pull request as ready for review April 29, 2025 08:11
@elmattic elmattic requested a review from a team as a code owner April 29, 2025 08:11
@elmattic elmattic requested review from LesnyRumcajs and sudo-shashank and removed request for a team April 29, 2025 08:11
);
let mut url = Url::parse(&base_url).ok()?;
url.query_pairs_mut()
.append_pair("cachebust", &Utc::now().timestamp().to_string());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's document what is cachebust.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

- run `cargo test --lib -- --test rpc_regression_tests --nocapture`
- Manual Method

1. Upload the test snapshots (`.zst` format is recommended) to the Digital Ocean space `forest-snapshots/rpc_test`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we mention to upload only .zst format to the DO space for these test snapshots instead of recommending?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, in practice, we always compress the files before uploading, and the script handles that automagically.

Copy link
Contributor

@sudo-shashank sudo-shashank left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM👍🏻

BUCKET_URL="s3://${SPACE_NAME}/${DEST_PATH}"

if zstd -f "$FILE_PATH" -o "$COMPRESSED_FILE"; then
if s3cmd --quiet --no-progress put "${COMPRESSED_FILE}" "${BUCKET_URL}" --acl-public --mime-type="application/json" --add-header="Cache-Control: no-cache, no-store, must-revalidate"; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s3cmd is not a standard tool. It'd be good UX to have a check at the beginning of the script if it's in PATH and if not, nag the user.

DEST_PATH="${DEST_DIR}/${FILE_NAME}.zst"
BUCKET_URL="s3://${SPACE_NAME}/${DEST_PATH}"

if zstd -f "$FILE_PATH" -o "$COMPRESSED_FILE"; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, can we simplify things via set -euo pipefail? I think error handling would be better this way.

Comment on lines +4 to +13
filecoin_chaingetevents_1745400136273439.rpcsnap.json.zst
filecoin_chaingetevents_1745400136273611.rpcsnap.json.zst
filecoin_chaingetevents_1745400136273670.rpcsnap.json.zst
filecoin_chaingetevents_1745400136273739.rpcsnap.json.zst
filecoin_chaingetevents_1745400136273790.rpcsnap.json.zst
filecoin_chaingetevents_1745400136273834.rpcsnap.json.zst
filecoin_chaingetevents_1745400136273881.rpcsnap.json.zst
filecoin_chaingetevents_1745400136273923.rpcsnap.json.zst
filecoin_chaingetevents_1745400136273969.rpcsnap.json.zst
filecoin_chaingetevents_1745400136274014.rpcsnap.json.zst
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need all of those snapshots? If yes, how are they different?

Copy link
Contributor Author

@elmattic elmattic Apr 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't really need them all. I can do some trimming. ✂️

@LesnyRumcajs
Copy link
Member

It'd be great to have a review from @hanabi1224 once he's back.

@LesnyRumcajs LesnyRumcajs requested a review from hanabi1224 April 30, 2025 09:37
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.

Add support for writing indexed data in .rcpsnap.json file
3 participants