Skip to content

chore(swift-sdk): script to get spv stortage from iOS sim#3950

Open
ZocoLini wants to merge 1 commit into
v3.1-devfrom
chore/spv-storage-script
Open

chore(swift-sdk): script to get spv stortage from iOS sim#3950
ZocoLini wants to merge 1 commit into
v3.1-devfrom
chore/spv-storage-script

Conversation

@ZocoLini

@ZocoLini ZocoLini commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Script to easily extract the spv storage, making issues easier to debug

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

Summary by CodeRabbit

  • New Features

    • Added a utility script for developers to extract SPV storage from iOS Simulator app containers, with interactive device and network selection capabilities.
  • Chores

    • Updated git ignore patterns for SDK maintenance.

@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@ZocoLini, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 53 minutes and 32 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0590b91b-94d4-4445-8728-7dffda77955f

📥 Commits

Reviewing files that changed from the base of the PR and between 81ae65d and c265ba1.

📒 Files selected for processing (2)
  • packages/swift-sdk/.gitignore
  • packages/swift-sdk/get_spv_storage.sh
📝 Walkthrough

Walkthrough

A new Bash script get_spv_storage.sh is added to packages/swift-sdk/ that extracts SwiftExampleApp SPV storage from an iOS Simulator container using xcrun simctl and jq, with interactive device and network selection. The .gitignore is updated to exclude the spv-storage-*/ output directories the script produces.

Changes

SPV Storage Extraction Utility

Layer / File(s) Summary
SPV extraction script and .gitignore output exclusion
packages/swift-sdk/get_spv_storage.sh, packages/swift-sdk/.gitignore
Adds a 254-line Bash script with CLI flag parsing (--bundle-id, --out, --device, --network), simulator enumeration via xcrun simctl and jq, app container resolution, SPV root verification, network selection (all, exact/prefix match, or interactive picker with du sizes), and timestamped copy of SPV directories to a local output path. Updates .gitignore to ignore spv-storage-*/ output directories alongside the existing logs-*/ pattern.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • shumkov
  • QuantumExplorer
  • llbartekll

Poem

🐰 Hopping through the simulator's maze,
With xcrun simctl and jq's gaze,
I sniff out the SPV with a timestamped hop,
Copy it cleanly—no reason to stop!
.gitignore guards the output with care,
A swift little rabbit, beyond compare! 🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title describes the main change (adding a script to extract SPV storage from iOS simulator), but contains a typo ('stortage' instead of 'storage') which slightly diminishes clarity.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/spv-storage-script

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@thepastaclaw

thepastaclaw commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

✅ Review complete (commit c265ba1)

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Code Review

PR adds a Bash helper to extract SwiftExampleApp SPV storage from a booted iOS Simulator, plus a matching .gitignore entry. The script is solid (set -euo pipefail, Bash 3.2 aware, interactive pickers with sane defaults) and touches no consensus/Rust code. One material reliability issue worth fixing for the script's stated debugging purpose, plus one minor robustness nit.

🟡 1 suggestion(s) | 💬 1 nitpick(s)

🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `packages/swift-sdk/get_spv_storage.sh`:
- [SUGGESTION] packages/swift-sdk/get_spv_storage.sh:248-253: Repeated runs merge stale files into the extracted SPV store
  `mkdir -p "$OUT_DIR"` followed by `cp -R "$src/." "$OUT_DIR/"` overlays a fresh dump onto whatever is already in `OUT_DIR`. If the SPV store has shed/rotated/compacted segment or metadata files between runs, the older files linger in the destination and silently corrupt the snapshot. Since this script exists specifically to debug SPV storage state, a misleading hybrid dump is the worst-case failure mode. Either refuse to write into a non-empty destination, timestamp the default `OUT_DIR`, or stage into a temp dir and replace atomically.

Comment thread packages/swift-sdk/get_spv_storage.sh
Comment thread packages/swift-sdk/get_spv_storage.sh Outdated
@ZocoLini ZocoLini marked this pull request as draft June 23, 2026 07:23
@ZocoLini ZocoLini force-pushed the chore/spv-storage-script branch 2 times, most recently from ab4164a to 81ae65d Compare June 23, 2026 10:50
@ZocoLini ZocoLini marked this pull request as ready for review June 23, 2026 10:51

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
packages/swift-sdk/get_spv_storage.sh (1)

250-251: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Prevent stale snapshot overlay when --out already exists.

Line 250 + Line 251 currently merge new SPV files into any existing directory, which can leave deleted/rotated files behind and produce a corrupted debug snapshot. Refuse pre-existing output paths (or stage to a temp dir and replace atomically).

Suggested fix
 if [ -z "$OUT_DIR" ]; then
   stamp="$(date +%Y-%m-%dT%H-%M-%S)"
   OUT_DIR="spv-storage-${safe_name}-${label}-${stamp}"
+elif [ -e "$OUT_DIR" ]; then
+  echo "Output path already exists: $OUT_DIR" >&2
+  echo "Choose a different --out path or remove it first." >&2
+  exit 1
 fi
 
 mkdir -p "$OUT_DIR"
 cp -R "$src/." "$OUT_DIR/"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/swift-sdk/get_spv_storage.sh` around lines 250 - 251, The current
implementation uses cp -R to merge files into the output directory, which can
leave stale files behind if OUT_DIR already exists. Fix this by either checking
if OUT_DIR exists before proceeding and refusing to continue (with an
appropriate error message), or by staging files to a temporary directory first
and then atomically replacing the final output directory. This ensures a clean
snapshot without leftover deleted or rotated files that could corrupt the debug
output.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@packages/swift-sdk/get_spv_storage.sh`:
- Around line 250-251: The current implementation uses cp -R to merge files into
the output directory, which can leave stale files behind if OUT_DIR already
exists. Fix this by either checking if OUT_DIR exists before proceeding and
refusing to continue (with an appropriate error message), or by staging files to
a temporary directory first and then atomically replacing the final output
directory. This ensures a clean snapshot without leftover deleted or rotated
files that could corrupt the debug output.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8b86b5c3-b3d9-4ebf-a58a-59f3cbfe6e63

📥 Commits

Reviewing files that changed from the base of the PR and between c1ab74e and 81ae65d.

📒 Files selected for processing (2)
  • packages/swift-sdk/.gitignore
  • packages/swift-sdk/get_spv_storage.sh

Comment thread packages/swift-sdk/get_spv_storage.sh

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Code Review

PR adds a developer utility shell script to extract SPV storage from the iOS Simulator and a .gitignore entry. Non-consensus-critical, self-contained. The script works as intended; only minor polish suggestions remain, the most substantive being that an explicit --out directory is silently merged into rather than checked for existing contents.

🟡 1 suggestion(s) | 💬 2 nitpick(s)

🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `packages/swift-sdk/get_spv_storage.sh`:
- [SUGGESTION] packages/swift-sdk/get_spv_storage.sh:245-251: Existing `--out` directory is silently merged into
  When the caller passes `--out`, `mkdir -p` followed by `cp -R "$src/." "$OUT_DIR/"` overlays the SPV snapshot on top of whatever already lives at that path. Files that have since been rotated or deleted from the simulator store will remain in the exported directory, producing a snapshot that no longer matches the selected simulator/network — exactly the kind of corrupt artifact a debug tool must not produce. Either refuse a non-empty target or remove it atomically before copying. The default timestamped path is unaffected.

Comment thread packages/swift-sdk/get_spv_storage.sh
Comment thread packages/swift-sdk/get_spv_storage.sh
Comment thread packages/swift-sdk/get_spv_storage.sh Outdated
shumkov
shumkov previously approved these changes Jun 23, 2026

@shumkov shumkov left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

we move to scripts in next PR

@ZocoLini ZocoLini force-pushed the chore/spv-storage-script branch from e3604ad to c265ba1 Compare June 25, 2026 12:03

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Code Review

PR #3950 adds a developer debug script get_spv_storage.sh that extracts SwiftExampleApp's SPV storage from an iOS Simulator, plus a .gitignore entry for its outputs. No production code, FFI, consensus, or Rust paths are touched. Carried-forward findings (silent merge into existing --out, narrow safe_name sanitization) remain valid; the prior indentation issue in pick_network is now fixed. New-delta findings are limited to a minor ambiguity in --device substring matching.

💬 1 nitpick(s)

2 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.

Comment thread packages/swift-sdk/get_spv_storage.sh
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.

3 participants