-
Notifications
You must be signed in to change notification settings - Fork 1
chore: bump solana version to 3.0 #16
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
base: master
Are you sure you want to change the base?
Conversation
WalkthroughThis pull request refactors the crate by removing the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
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.
Actionable comments posted: 4
📜 Review details
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (7)
Cargo.tomlsrc/lib.rssrc/processors/register.rssrc/processors/sync.rssrc/processors/unregister.rssrc/solana_compact.rstests/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::transfertosolana_system_interface::instruction::transferaligns 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_accounttosolana_system_interface::instruction::create_accountproperly aligns with the Solana 3.0 modular SDK structure and the removal of thesolana_compactabstraction layer.src/processors/unregister.rs (1)
67-68: Account closure pattern is correct, but depends on validsystem_programkey.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 passPubkey::default()(as seen intests/common.rs), this would assign the account to an invalid owner.Consider adding validation that
system_program.keyis actually the system program:use solana_program::system_program; if *system_program.key != system_program::ID { return Err(ProgramError::IncorrectProgramId); }
| solana-program = { version = ">=1.6" } | ||
| solana-system-interface = { version = ">=1", features = ["bincode"] } |
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.
🧹 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.
| 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"] } |
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.
🧩 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:
- ProgramTestContext docs (agave-unstable-api deprecation note). [1] (docs.rs)
- solana-program-test features page (agave-unstable-api feature). [2] (docs.rs)
Citations:
- 1: https://docs.rs/solana-program-test/latest/solana_program_test/struct.ProgramTestContext.html?utm_source=openai
- 2: https://docs.rs/crate/solana-program-test/3.1.4/features?utm_source=openai
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.
| 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)?; |
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.
🧩 Analysis chain
🏁 Script executed:
# First, let's check the resize method usage in the codebase
rg -n 'resize\s*\(' --type rust -A 1 -B 1Repository: 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 catRepository: 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 -20Repository: 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 rustRepository: 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 -20Repository: 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 forrealloc. [1][2][3]
References
- Solana Stack Exchange — “use of deprecated method … realloc: Use AccountInfo::resize() instead.”. [link].
- Solana Stack Exchange — “no method named
resizefound …” (recommendation: cargo update solana-account-info --precise 2.3.0). [link]. - 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 -30Repository: 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 tomlRepository: 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), |
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.
🧩 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 -70Repository: 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 -70Repository: 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 2Repository: 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 rustRepository: magicblock-labs/magic-domain-program
Length of output: 62
🏁 Script executed:
# Check imports at the top of tests/common.rs
head -50 tests/common.rsRepository: 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 solanaRepository: 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 rustRepository: 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.rsRepository: 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.rsRepository: 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.
Summary by CodeRabbit
Refactor
Chores
✏️ Tip: You can customize this high-level summary in your review settings.