Skip to content

Conversation

@bmuddha
Copy link
Collaborator

@bmuddha bmuddha commented Dec 26, 2025

Summary by CodeRabbit

  • Refactor

    • Simplified internal code architecture by removing unused abstraction layers to enhance code maintainability
  • Chores

    • Bumped package version to 0.3.0
    • Updated and streamlined core dependencies with improved long-term compatibility
    • Removed obsolete and unused feature flags from package configuration
    • Restructured internal code organization for better maintainability and clarity

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 26, 2025

Walkthrough

This pull request refactors the crate by removing the solana_compact abstraction layer and updating dependencies. Changes include loosening version constraints, reordering serialization dependencies, removing feature flags, and updating import paths across processor files to use direct dependencies like solana_system_interface. Test utilities are also updated to use Pubkey::default() instead of system_program::ID.

Changes

Cohort / File(s) Summary
Dependency Configuration
Cargo.toml
Version bumped to 0.3.0; loosened solana-program constraint from >=1.6, <3.0.0 to >=1.6; reordered and updated serialization dependencies (borsh reintroduced with derive feature, bytemuck_derive bumped to >=1.0); added agave-unstable-api feature to solana-program-test; removed obsolete disable-realloc and modular-sdk feature entries; keywords array reformatted to multi-line with "magicblock" addition.
Module Structure
src/lib.rs, src/solana_compact.rs
Removed mod solana_compact; from lib.rs; deleted src/solana_compact.rs entirely, eliminating the public resize() helper function and feature-gated solana module that abstracted between solana_program::system_instruction and solana_system_interface::instruction.
Processor Import Updates
src/processors/register.rs, src/processors/sync.rs, src/processors/unregister.rs
Updated imports to use solana_system_interface::instruction::create_account and transfer instead of routing through solana_compact; replaced external resize() calls with AccountInfo::resize() inherent method; simplified local crate imports to only necessary exports.
Test Updates
tests/common.rs
Replaced system_program::ID references with Pubkey::default() in account setup and transaction construction across multiple test functions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • chore: solana-program cap <3.0.0 #14 — Directly related: modifies the same solana-program dependency constraint in Cargo.toml, adjusting version bounds in opposing directions.
  • Feat/sdk compatibility #13 — Directly related: both PRs remove/modify src/solana_compact.rs and change how resize() and system_instruction are imported and used across processor files.

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Title check ⚠️ Warning The title claims to bump solana version to 3.0, but the actual changes loosen the solana-program constraint from '>=1.6, <3.0.0' to '>=1.6', removing the upper bound rather than upgrading to 3.0. Revise the title to accurately reflect the changes, such as 'chore: remove solana-program version upper bound' or 'chore: loosen solana-program dependency constraints'.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bmuddha/chore/bump-solana-version

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 and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cffcfeb and 9511d5b.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (7)
  • Cargo.toml
  • src/lib.rs
  • src/processors/register.rs
  • src/processors/sync.rs
  • src/processors/unregister.rs
  • src/solana_compact.rs
  • tests/common.rs
💤 Files with no reviewable changes (2)
  • src/solana_compact.rs
  • src/lib.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: install
🔇 Additional comments (4)
src/processors/sync.rs (1)

9-9: Import path updated correctly.

The migration from system_instruction::transfer to solana_system_interface::instruction::transfer aligns with the Solana 3.0 modular SDK structure.

tests/common.rs (1)

35-35: Account owner change looks correct for native accounts.

Using Pubkey::default() as the owner for a newly created account with lamports is acceptable here since native SOL accounts (system-owned) can use the default pubkey in test contexts. The actual ownership semantics are handled by the runtime.

src/processors/register.rs (1)

10-12: Import migration looks correct.

The change from solana_compact::solana::system_instruction::create_account to solana_system_interface::instruction::create_account properly aligns with the Solana 3.0 modular SDK structure and the removal of the solana_compact abstraction layer.

src/processors/unregister.rs (1)

67-68: Account closure pattern is correct, but depends on valid system_program key.

The sequence of transferring lamports, reassigning ownership, and resizing to zero is the correct pattern for closing a PDA. However, note that pda_account.assign(system_program.key) uses the key passed in the accounts list. If tests incorrectly pass Pubkey::default() (as seen in tests/common.rs), this would assign the account to an invalid owner.

Consider adding validation that system_program.key is actually the system program:

use solana_program::system_program;

if *system_program.key != system_program::ID {
    return Err(ProgramError::IncorrectProgramId);
}

Comment on lines +26 to +27
solana-program = { version = ">=1.6" }
solana-system-interface = { version = ">=1", features = ["bincode"] }
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Consider adding upper bounds to version constraints for stability.

Open-ended version constraints like >=1.6 without an upper bound can lead to unexpected breakages when new major versions with breaking changes are released. For a Solana program crate, this is particularly risky as major Solana SDK updates often contain breaking changes.

🔎 Suggested version constraints
-solana-program = { version = ">=1.6" }
-solana-system-interface = { version = ">=1", features = ["bincode"] }
+solana-program = { version = ">=1.6, <4" }
+solana-system-interface = { version = ">=1, <2", features = ["bincode"] }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
solana-program = { version = ">=1.6" }
solana-system-interface = { version = ">=1", features = ["bincode"] }
solana-program = { version = ">=1.6, <4" }
solana-system-interface = { version = ">=1, <2", features = ["bincode"] }
🤖 Prompt for AI Agents
In Cargo.toml around lines 26-27, the dependency version constraints use
open-ended lower bounds (">=...") which can allow breaking major releases;
update them to add explicit upper bounds (e.g., constrain to the current major
version range such as ">=1.6, <2.0" for solana-program and ">=1, <2.0" for
solana-system-interface) while preserving existing features (bincode) so builds
remain stable but receive compatible updates.

solana-sdk = { version = ">=1.6" }
solana-program-test = { version = ">=1.6" }
tokio = { version = ">=1", features = [ "macros", "rt" ] }
solana-program-test = { version = ">=1.6", features = ["agave-unstable-api"] }
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🌐 Web query:

agave-unstable-api feature solana-program-test

💡 Result:

Enable the feature in your Cargo.toml dependency. Example:

solana-program-test = { version = "3.1.4", features = ["agave-unstable-api"] }

Docs note: ProgramTest/ProgramTestContext are marked as part of the Agave Unstable API and from v4.0.0 you must opt into the agave-unstable-api feature to acknowledge unstable interfaces. [1][2]

Sources:

  1. ProgramTestContext docs (agave-unstable-api deprecation note). [1] (docs.rs)
  2. solana-program-test features page (agave-unstable-api feature). [2] (docs.rs)

Citations:


Acknowledge intentional opt-in for unstable APIs and monitor for breaking changes.

The agave-unstable-api feature is required (as of v4.0.0) to access unstable interfaces like ProgramTest/ProgramTestContext. The opt-in design is intentional; ensure the project is prepared to adapt tests if these unstable APIs change in future releases.

🤖 Prompt for AI Agents
In Cargo.toml around line 36, the solana-program-test dependency uses the
agave-unstable-api feature which is an intentional opt-in for unstable Solana
APIs; add an inline comment immediately above this dependency noting that
agave-unstable-api is intentionally enabled, that tests rely on unstable
ProgramTest/ProgramTestContext, and that maintainers must monitor Solana
releases for breaking changes; additionally register this dependency in the
project README or CHANGELOG and add/update a lightweight CI/issue reminder to
track new solana-program-test releases so tests can be adapted when the unstable
API changes.

Comment on lines 70 to +79
if rent_new > rent_old {
invoke(
&system_instruction::transfer(payer.key, pda_account.key, rent_new - rent_old),
&transfer(payer.key, pda_account.key, rent_new - rent_old),
&[payer.clone(), pda_account.clone(), system_program.clone()],
)?;
} else {
**pda_account.try_borrow_mut_lamports()? -= rent_old - rent_new;
**payer.try_borrow_mut_lamports()? += rent_old - rent_new;
}
resize(pda_account, new_size)?;
pda_account.resize(new_size)?;
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, let's check the resize method usage in the codebase
rg -n 'resize\s*\(' --type rust -A 1 -B 1

Repository: magicblock-labs/magic-domain-program

Length of output: 417


🏁 Script executed:

# Check the project dependencies and Solana version
fd -t f 'Cargo.toml' | head -5 | xargs cat

Repository: magicblock-labs/magic-domain-program

Length of output: 1169


🏁 Script executed:

# Look for AccountInfo type definition or imports
rg -n 'AccountInfo' --type rust | grep -E '(use|import|struct)' | head -20

Repository: magicblock-labs/magic-domain-program

Length of output: 62


🏁 Script executed:

# Check if AccountInfo is from solana-program and look at how it's used
rg -n 'impl.*AccountInfo|pub fn resize' --type rust

Repository: magicblock-labs/magic-domain-program

Length of output: 350


🏁 Script executed:

# Search for AccountInfo imports to understand where it comes from
rg -n 'use.*AccountInfo|from solana_program' --type rust | head -20

Repository: magicblock-labs/magic-domain-program

Length of output: 62


🌐 Web query:

solana-program AccountInfo resize method availability version history

💡 Result:

Short answer

  • The AccountInfo::resize(...) method was introduced in solana-account-info v2.3.0 (replacing/deprecating the earlier AccountInfo::realloc). [1][2]

Details / evidence

  • Multiple community threads and fixes state that the resize method was added in solana-account-info 2.3.0 and that projects should update to that version when they see errors like “no method named resize …” or deprecation warnings for realloc. [1][2][3]

References

  1. Solana Stack Exchange — “use of deprecated method … realloc: Use AccountInfo::resize() instead.”. [link].
  2. Solana Stack Exchange — “no method named resize found …” (recommendation: cargo update solana-account-info --precise 2.3.0). [link].
  3. Solana Cookbook / docs on realloc/resize and account-size migration. [link].

🏁 Script executed:

# Check if there's a Cargo.lock to see the resolved versions
fd -t f 'Cargo.lock' -x cat {} | grep -A 5 'solana-program\|solana-account-info' | head -30

Repository: magicblock-labs/magic-domain-program

Length of output: 62


🏁 Script executed:

# Look for version resolution or exact dependencies
rg -n 'solana-program|solana-account-info' --type toml

Repository: magicblock-labs/magic-domain-program

Length of output: 225


🌐 Web query:

solana-program 1.6 solana-account-info version dependency

💡 Result:

solana-program 1.6 expects the matching solana-account-info 1.6 (Solana SDK crates keep matching minor versions; use the same x.y version for solana-account-info as solana-program). [1][2]

Sources:

  • Solana Rust SDK docs (program crate guidance). [1]
  • solana-account-info crate listings (Solana SDK crates follow aligned versions). [2]

Would you like me to look up the exact crates.io/docs.rs pages for 1.6 versions and paste the Cargo.toml lines?


🌐 Web query:

solana-account-info 1.6 resize method available or realloc deprecated

💡 Result:

Short answer: resize is not available in solana-account-info 1.6 — the resize method was added in later releases (solana-account-info v2.3.0) and realloc was deprecated in favor of AccountInfo::resize. [1][2]

Sources:

  • solana-account-info release / crate history showing newer versions where resize was added. [1]
  • Discussion noting realloc deprecated and recommending AccountInfo::resize (references v2.3.0). [2]

🌐 Web query:

solana-program "1.6" release notes AccountInfo method changes

💡 Result:

solana-program v1.6 introduced a refactor of AccountInfo to expose safe accessor/borrow methods (e.g. lamports(), data_len(), data_is_empty(), try_borrow_data()/try_borrow_mut_data(), try_borrow_lamports()/try_borrow_mut_lamports(), etc.) and to use interior‑mutability wrappers for lamports/data so programs use the try_borrow_* APIs rather than direct &mut access. See the solana-program crate source for v1.6.1 (AccountInfo usage) and later versions showing the accessor/try_borrow API. [1][2]

Sources:

  • solana-program 1.6.1 source (AccountInfo usage). [1]
  • solana-program (later version) AccountInfo with accessor and try_borrow_* methods. [2]

Pin solana-account-info version to 2.3.0+ or document minimum Solana version requirement.

The resize method on AccountInfo is available only in solana-account-info v2.3.0 and later (replacing the deprecated realloc method). The current Cargo.toml specifies solana-program = { version = ">=1.6" }, which does not guarantee the availability of this method. Either add an explicit version constraint for solana-account-info >= 2.3.0 or clearly document that this code requires a minimum Solana version that includes the resize API.

🤖 Prompt for AI Agents
In src/processors/sync.rs around lines 70 to 79 the code calls
pda_account.resize(new_size)? which requires solana-account-info v2.3.0+ (the
resize API replaces realloc); update Cargo.toml to explicitly pin
solana-account-info = ">=2.3.0" (or add a corresponding solana-program version
that guarantees that transitive dependency), run cargo update and cargo build to
verify, or alternatively add a clear comment/README entry documenting the
minimum Solana toolchain/version required (>= the release that introduced
solana-account-info v2.3.0) so users know the API dependency.

AccountMeta::new(identity.pubkey(), true),
AccountMeta::new(pda, false),
AccountMeta::new_readonly(system_program::ID, false),
AccountMeta::new_readonly(Pubkey::default(), false),
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, let's look at the specific lines in tests/common.rs
cd /dev/null # just to be safe
cat -n tests/common.rs | head -130 | tail -70

Repository: magicblock-labs/magic-domain-program

Length of output: 3011


🏁 Script executed:

# Also check what context is around those lines - get more context
head -130 tests/common.rs | tail -70

Repository: magicblock-labs/magic-domain-program

Length of output: 2454


🏁 Script executed:

# Search for system_program usage in the codebase
rg -n 'system_program' --type rust -A 2 -B 2

Repository: magicblock-labs/magic-domain-program

Length of output: 2040


🏁 Script executed:

# Check if system_program::ID is used elsewhere in the codebase
rg -n 'system_program::ID' --type rust

Repository: magicblock-labs/magic-domain-program

Length of output: 62


🏁 Script executed:

# Check imports at the top of tests/common.rs
head -50 tests/common.rs

Repository: magicblock-labs/magic-domain-program

Length of output: 1538


🏁 Script executed:

# Check Cargo.toml for solana_sdk dependency
cat Cargo.toml | grep -A 5 -B 5 solana

Repository: magicblock-labs/magic-domain-program

Length of output: 964


🏁 Script executed:

# Check if there are any other test files using system_program::ID or similar
rg -n 'solana_sdk::system_program\|use.*system_program' --type rust

Repository: magicblock-labs/magic-domain-program

Length of output: 62


🏁 Script executed:

# Verify system_program is a standard module in solana_sdk by checking if it's used in processor imports
head -30 src/processors/register.rs

Repository: magicblock-labs/magic-domain-program

Length of output: 1140


🏁 Script executed:

# Check if any Solana SDK documentation confirms system_program::ID availability
head -30 src/processors/sync.rs

Repository: magicblock-labs/magic-domain-program

Length of output: 1074


Replace Pubkey::default() with system_program::ID for system program accounts.

The system program account in AccountMeta::new_readonly must reference the actual system program ID (11111111111111111111111111111111), not Pubkey::default() (all zeros). The processors explicitly extract and invoke this account in CPI calls (invoke_signed and invoke), which will fail on mainnet/devnet if the wrong program ID is provided. While BanksClient may not strictly validate, this causes runtime failures on actual Solana clusters.

Add the import and update all three functions:

+use solana_sdk::system_program;

Then replace Pubkey::default() with system_program::ID at lines 71, 91, and 122.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In tests/common.rs around lines 71, 91, and 122, replace the incorrect zeroed
Pubkey::default() used for system program accounts with the actual system
program ID (system_program::ID); add the appropriate import (for example bring
system_program::ID into scope via use solana_program::system_program;) and
update each AccountMeta::new_readonly(Pubkey::default(), false) to
AccountMeta::new_readonly(system_program::ID, false) so CPI/invoke calls
reference the real system program account.

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.

2 participants