Skip to content

feat: update to legacy SDK - #123

Open
Dodecahedr0x wants to merge 3 commits into
mainfrom
dode/crank-refactor
Open

feat: update to legacy SDK#123
Dodecahedr0x wants to merge 3 commits into
mainfrom
dode/crank-refactor

Conversation

@Dodecahedr0x

@Dodecahedr0x Dodecahedr0x commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

The current example manually builds the crank schedule. Uses the SDK instead (legacy cranks, not Hydra)

Summary by CodeRabbit

  • New Features

    • Updated the crank counter to use the latest scheduling workflow for recurring increments.
    • Added support for preloading an account fixture during local development.
  • Bug Fixes

    • Improved scheduled increment reliability by waiting for on-chain updates instead of relying on a fixed delay.
  • Tests

    • Enhanced integration checks to verify initialization, delegation, scheduled increments, and undelegation results.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@Dodecahedr0x, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 34 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

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 reviews.

How do review 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 refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4c3d7431-1280-447b-a472-b7dc6786fc90

📥 Commits

Reviewing files that changed from the base of the PR and between 3b104e8 and f94f83e.

⛔ Files ignored due to path filters (1)
  • crank-counter/anchor/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • crank-counter/anchor/programs/crank-counter/Cargo.toml
  • crank-counter/anchor/programs/crank-counter/src/lib.rs

Walkthrough

Changes

Crank-counter SDK migration

Layer / File(s) Summary
Program identity and SDK CPI integration
crank-counter/anchor/Anchor.toml, crank-counter/anchor/programs/crank-counter/Cargo.toml, crank-counter/anchor/programs/crank-counter/src/lib.rs
Updates the program ID, pins the SDK to a git revision, and replaces manual task scheduling with ScheduleCrankCpi.
Anchor integration test flow
crank-counter/anchor/tests/crank-counter.ts
Uses typed Anchor RPC calls, asserts initialization, polls for scheduled increments, and uses RPC for delegation and undelegation.
Local account preload configuration
scripts/mAGicPQYBMvcYveUZA5F5UNNwyHvfYh5xkLS2Fr1mev.json, scripts/test-locally.sh
Adds account metadata and preloads the account when starting the local stack.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: dhruvja

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: switching the example to the legacy SDK for crank scheduling.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dode/crank-refactor

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.

@vercel

vercel Bot commented Jul 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
binary-prediction-demo Ready Ready Preview, Comment Jul 22, 2026 4:54pm
counter-session-keys Ready Ready Preview, Comment Jul 22, 2026 4:54pm
er-rolldice Ready Ready Preview, Comment Jul 22, 2026 4:54pm
magicblock-counter-example Ready Ready Preview, Comment Jul 22, 2026 4:54pm
magicblock-engine-examples Ready Ready Preview, Comment Jul 22, 2026 4:54pm
magicblock-rewards-dashboard Ready Ready Preview, Comment Jul 22, 2026 4:54pm
rps-example Ready Ready Preview, Comment Jul 22, 2026 4:54pm
spl-tokens Ready Ready Preview, Comment Jul 22, 2026 4:54pm

Request Review

@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.

Actionable comments posted: 2

🤖 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.

Inline comments:
In `@crank-counter/anchor/Anchor.toml`:
- Around line 8-11: Update the crank_counter value under [programs.localnet] to
6avjV8kWVhVf2NX6ZeE7SaqyqjRnCD6JDwhiUH6yFymz, matching declare_id! and
[programs.devnet].

In `@crank-counter/anchor/programs/crank-counter/Cargo.toml`:
- Around line 25-31: Remove the unused sha2 and bincode dependency entries from
the crank-counter program’s Cargo.toml, leaving the ephemeral-rollups-sdk
configuration and other dependencies unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 6caf4dc2-0047-47e9-a1c9-b04e723f6e25

📥 Commits

Reviewing files that changed from the base of the PR and between a2cd230 and 3b104e8.

⛔ Files ignored due to path filters (1)
  • crank-counter/anchor/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (6)
  • crank-counter/anchor/Anchor.toml
  • crank-counter/anchor/programs/crank-counter/Cargo.toml
  • crank-counter/anchor/programs/crank-counter/src/lib.rs
  • crank-counter/anchor/tests/crank-counter.ts
  • scripts/mAGicPQYBMvcYveUZA5F5UNNwyHvfYh5xkLS2Fr1mev.json
  • scripts/test-locally.sh

Comment on lines 8 to 11
[programs.devnet]
crank_counter = "HetkBSVTbemvzJzcmnTS6Ge6LP9KVVXkbtdL6qguG2g9"
crank_counter = "6avjV8kWVhVf2NX6ZeE7SaqyqjRnCD6JDwhiUH6yFymz"

[programs.localnet]

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
cat crank-counter/anchor/Anchor.toml

Repository: magicblock-labs/magicblock-engine-examples

Length of output: 593


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== Anchor.toml ==\n'
cat -n crank-counter/anchor/Anchor.toml

printf '\n== lib.rs ==\n'
cat -n crank-counter/anchor/programs/crank_counter/src/lib.rs

printf '\n== tests ==\n'
rg -n "localnet|devnet|crank_counter|declare_id" crank-counter/anchor/tests crank-counter/anchor/programs/crank_counter/src -S

Repository: magicblock-labs/magicblock-engine-examples

Length of output: 860


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== candidate files ==\n'
fd -a 'lib.rs$|Anchor.toml$|crank-counter.ts$' crank-counter/anchor

printf '\n== program source outline ==\n'
ast-grep outline crank-counter/anchor/programs --match 'declare_id!($_)' --view expanded || true

printf '\n== test references ==\n'
rg -n "FW2QPnTK9WwYLNG29GhH7PGYdp7Jwq3pGQrUuNdUnK44|6avjV8kWVhVf2NX6ZeE7SaqyqjRnCD6JDwhiUH6yFymz|declare_id|localnet" crank-counter/anchor -S

Repository: magicblock-labs/magicblock-engine-examples

Length of output: 830


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== Anchor.toml ==\n'
cat -n crank-counter/anchor/Anchor.toml

printf '\n== package.json ==\n'
cat -n crank-counter/anchor/package.json

printf '\n== tests/crank-counter.ts ==\n'
cat -n crank-counter/anchor/tests/crank-counter.ts

Repository: magicblock-labs/magicblock-engine-examples

Length of output: 8114


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== local-env.sh ==\n'
cat -n scripts/local-env.sh

printf '\n== any Anchor env overrides ==\n'
rg -n "ANCHOR_PROVIDER_URL|ANCHOR_WALLET|ANCHOR_CLUSTER|LOCALNET|devnet|localnet" scripts crank-counter/anchor -S

Repository: magicblock-labs/magicblock-engine-examples

Length of output: 4589


Update [programs.localnet] to the new program ID. It still points to FW2QPnTK9WwYLNG29GhH7PGYdp7Jwq3pGQrUuNdUnK44 while declare_id! and [programs.devnet] use 6avjV8kWVhVf2NX6ZeE7SaqyqjRnCD6JDwhiUH6yFymz.

🤖 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 `@crank-counter/anchor/Anchor.toml` around lines 8 - 11, Update the
crank_counter value under [programs.localnet] to
6avjV8kWVhVf2NX6ZeE7SaqyqjRnCD6JDwhiUH6yFymz, matching declare_id! and
[programs.devnet].

Comment on lines +25 to 31
# TODO: Remove this once the SDK is published to crates.io
ephemeral-rollups-sdk = { git = "https://github.com/magicblock-labs/ephemeral-rollups-sdk.git", rev = "086eeaa0e9fcd12d442d78bcd40817a782521cbc", features = [
"anchor",
"crank",
] }
sha2 = "0.10"
magicblock-magic-program-api = { version = "0.10.1", default-features = false }
bincode = "^1.3"

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.

🎯 Functional Correctness | 🔵 Trivial | 💤 Low value

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
rg -n 'magicblock_magic_program_api|bincode::|sha2::|MagicBlockInstruction|invoke_signed' crank-counter/anchor/programs/crank-counter/src/lib.rs

Repository: magicblock-labs/magicblock-engine-examples

Length of output: 180


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Cargo.toml =="
nl -ba crank-counter/anchor/programs/crank-counter/Cargo.toml | sed -n '1,120p'

echo
echo "== Search entire crate for relevant symbols =="
rg -n 'magicblock_magic_program_api|bincode::|sha2::|MagicBlockInstruction|invoke_signed|magic_context|MAGIC_CONTEXT_ID' crank-counter/anchor/programs/crank-counter

echo
echo "== File list =="
git ls-files crank-counter/anchor/programs/crank-counter

Repository: magicblock-labs/magicblock-engine-examples

Length of output: 237


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Cargo.toml =="
cat -n crank-counter/anchor/programs/crank-counter/Cargo.toml | sed -n '1,120p'

echo
echo "== Search entire crate for relevant symbols =="
rg -n 'magicblock_magic_program_api|bincode::|sha2::|MagicBlockInstruction|invoke_signed|magic_context|MAGIC_CONTEXT_ID' crank-counter/anchor/programs/crank-counter

echo
echo "== File list =="
git ls-files crank-counter/anchor/programs/crank-counter

Repository: magicblock-labs/magicblock-engine-examples

Length of output: 1576


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== lib.rs (top section) =="
cat -n crank-counter/anchor/programs/crank-counter/src/lib.rs | sed -n '1,180p'

echo
echo "== Search whole repo for removed crate name =="
rg -n 'magicblock_magic_program_api|magicblock-magic-program-api' .

echo
echo "== Search whole repo for sha2/bincode usage in this crate =="
rg -n '\bsha2\b|\bbincode\b' crank-counter/anchor/programs/crank-counter

Repository: magicblock-labs/magicblock-engine-examples

Length of output: 10675


Remove the unused sha2 and bincode dependencies. They no longer appear in crank-counter/anchor/programs/crank-counter/src/lib.rs.

🤖 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 `@crank-counter/anchor/programs/crank-counter/Cargo.toml` around lines 25 - 31,
Remove the unused sha2 and bincode dependency entries from the crank-counter
program’s Cargo.toml, leaving the ephemeral-rollups-sdk configuration and other
dependencies unchanged.

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.

1 participant