fix: add realloc to cpi context account reinit ix#2034
Conversation
WalkthroughSplit the single CPI context size constant into a deprecated V1 alias and a new V2 constant; updated code to prefer V2, added an ownership check and pre-read before resizing the CPI context account, added a remaining_capacity() accessor, and enabled/adjusted several tests (including test-sbf gating and V1/V2 size assertions). Changes
Sequence Diagram(s)sequenceDiagram
participant Handler as init_context_account handler
participant CPI as cpi_context_account
participant AMT as associated_merkle_tree
Handler->>CPI: verify ownership
Note right of CPI `#DDEEFF`: Ownership must be valid\nbefore any resize/truncation
Handler->>CPI: read associated_merkle_tree (pre-read)
Handler->>CPI: resize account to DEFAULT_CPI_CONTEXT_ACCOUNT_SIZE_V2
Note right of Handler `#EFEFEF`: Uses V2 size constant\nand pre-read data to avoid loss
Handler->>CPI: write/init with pre-read associated_merkle_tree
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (11)
🚧 Files skipped from review as they are similar to previous changes (5)
🧰 Additional context used📓 Path-based instructions (1)sdk-tests/sdk-token-test/**/tests/**/*.rs📄 CodeRabbit inference engine (sdk-tests/sdk-token-test/CLAUDE.md)
Files:
🧠 Learnings (30)📓 Common learnings📚 Learning: 2025-10-11T21:59:25.222ZApplied to files:
📚 Learning: 2025-10-11T21:59:25.222ZApplied to files:
📚 Learning: 2025-10-11T21:59:25.222ZApplied to files:
📚 Learning: 2025-10-11T21:59:25.222ZApplied to files:
📚 Learning: 2025-10-16T06:33:19.426ZApplied to files:
📚 Learning: 2025-10-15T03:46:43.242ZApplied to files:
📚 Learning: 2025-10-11T21:59:25.222ZApplied to files:
📚 Learning: 2025-10-16T06:33:55.362ZApplied to files:
📚 Learning: 2025-10-16T06:33:55.362ZApplied to files:
📚 Learning: 2025-10-11T21:59:25.222ZApplied to files:
📚 Learning: 2025-10-15T03:46:26.767ZApplied to files:
📚 Learning: 2025-10-15T03:46:43.242ZApplied to files:
📚 Learning: 2025-10-11T21:59:25.222ZApplied to files:
📚 Learning: 2025-10-15T03:46:26.767ZApplied to files:
📚 Learning: 2025-10-15T03:46:26.767ZApplied to files:
📚 Learning: 2025-10-11T21:59:25.222ZApplied to files:
📚 Learning: 2025-10-15T03:46:26.767ZApplied to files:
📚 Learning: 2025-10-15T03:46:26.767ZApplied to files:
📚 Learning: 2025-10-16T06:33:19.426ZApplied to files:
📚 Learning: 2025-10-15T03:46:26.767ZApplied to files:
📚 Learning: 2025-10-11T21:59:25.222ZApplied to files:
📚 Learning: 2025-10-11T21:59:25.222ZApplied to files:
📚 Learning: 2025-10-16T06:33:19.426ZApplied to files:
📚 Learning: 2025-10-15T03:46:26.767ZApplied to files:
📚 Learning: 2025-10-11T21:59:25.222ZApplied to files:
📚 Learning: 2025-10-15T03:46:26.767ZApplied to files:
📚 Learning: 2025-10-11T21:59:25.222ZApplied to files:
📚 Learning: 2025-10-11T21:59:52.712ZApplied to files:
📚 Learning: 2025-10-11T21:59:25.222ZApplied to files:
🧬 Code graph analysis (2)programs/system/src/accounts/init_context_account.rs (2)
program-tests/system-test/tests/test_re_init_cpi_account.rs (1)
⏰ 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). (13)
🔇 Additional comments (1)
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 |
606091d to
704742b
Compare
5e7d403 to
668d75e
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
programs/system/src/accounts/init_context_account.rs (1)
80-86: Consider adding discriminator validation before deserialization.The pre-read of
associated_merkle_treebefore resizing is critical and correctly implemented to prevent data loss from truncation. However, consider adding discriminator validation before attempting to deserialize the account data, similar to howinit_cpi_context_accountvalidates the discriminator ofassociated_merkle_tree(lines 44-48).Add discriminator validation before deserialization:
// Read associated_merkle_tree BEFORE resizing (in case resize truncates data) let associated_merkle_tree = { let data = cpi_context_account.try_borrow_data()?; + + // Validate discriminator + let mut discriminator_bytes = [0u8; 8]; + discriminator_bytes.copy_from_slice(&data[0..8]); + if discriminator_bytes != CpiContextAccount::LIGHT_DISCRIMINATOR { + return Err(SystemProgramError::InvalidDiscriminator.into()); + } + CpiContextAccount::deserialize(&mut &data[8..]) .map_err(|_| ProgramError::BorshIoError)? .associated_merkle_tree };This would provide better error messages and prevent deserialization attempts on invalid account data.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (11)
program-libs/batched-merkle-tree/src/constants.rs(1 hunks)program-libs/batched-merkle-tree/src/initialize_state_tree.rs(5 hunks)program-libs/compressed-account/src/instruction_data/insert_into_queues.rs(1 hunks)program-tests/compressed-token-test/tests/mint/failing.rs(1 hunks)program-tests/system-cpi-test/tests/test_cpi_context_event.rs(1 hunks)program-tests/system-test/tests/test_re_init_cpi_account.rs(4 hunks)programs/registry/src/protocol_config/state.rs(1 hunks)programs/system/src/accounts/init_context_account.rs(2 hunks)programs/system/src/cpi_context/state.rs(1 hunks)sdk-tests/sdk-pinocchio-v1-test/tests/test.rs(1 hunks)sdk-tests/sdk-token-test/tests/test.rs(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (6)
- program-tests/system-cpi-test/tests/test_cpi_context_event.rs
- program-tests/system-test/tests/test_re_init_cpi_account.rs
- program-tests/compressed-token-test/tests/mint/failing.rs
- program-libs/batched-merkle-tree/src/constants.rs
- programs/system/src/cpi_context/state.rs
- program-libs/compressed-account/src/instruction_data/insert_into_queues.rs
🧰 Additional context used
📓 Path-based instructions (1)
sdk-tests/sdk-token-test/**/tests/**/*.rs
📄 CodeRabbit inference engine (sdk-tests/sdk-token-test/CLAUDE.md)
Every test should only contain functional integration tests
Files:
sdk-tests/sdk-token-test/tests/test.rs
🧠 Learnings (29)
📓 Common learnings
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/**/*.rs : CPI processing functions must derive PDA signer seeds as [CPI_AUTHORITY_PDA_SEED, bump] and use CpiContext::new_with_signer with cpi_authority as the authority account and mapped target accounts.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/*.rs : Context structs for wrapper instructions must include standard accounts: optional registered_forester_pda (mut), authority Signer, cpi_authority with seeds/bump for CPI_AUTHORITY_PDA_SEED, registered_program_pda, target program handle, log_wrapper, and mutable target_account.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/*.rs : Each new operation module must define an Anchor context struct (e.g., NewOperationContext) with required accounts and a process_<operation> function that prepares signer seeds, maps accounts to the target program, and executes the CPI.
📚 Learning: 2025-10-15T03:46:26.767Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/**/*.rs : Pass the data Vec<u8> through unchanged from the wrapper to the target program CPI; the target program performs deserialization.
Applied to files:
programs/registry/src/protocol_config/state.rsprogram-libs/batched-merkle-tree/src/initialize_state_tree.rsprograms/system/src/accounts/init_context_account.rssdk-tests/sdk-pinocchio-v1-test/tests/test.rs
📚 Learning: 2025-10-16T06:33:19.426Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:19.426Z
Learning: Applies to program-libs/compressible/src/config.rs : Provide default initialization for the CToken V1 config in CompressibleConfig
Applied to files:
programs/registry/src/protocol_config/state.rs
📚 Learning: 2025-10-15T03:46:26.767Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/**/*.rs : CPI processing functions must derive PDA signer seeds as [CPI_AUTHORITY_PDA_SEED, bump] and use CpiContext::new_with_signer with cpi_authority as the authority account and mapped target accounts.
Applied to files:
programs/registry/src/protocol_config/state.rsprogram-libs/batched-merkle-tree/src/initialize_state_tree.rsprograms/system/src/accounts/init_context_account.rs
📚 Learning: 2025-10-15T03:46:26.767Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/*.rs : Context structs for wrapper instructions must include standard accounts: optional registered_forester_pda (mut), authority Signer, cpi_authority with seeds/bump for CPI_AUTHORITY_PDA_SEED, registered_program_pda, target program handle, log_wrapper, and mutable target_account.
Applied to files:
program-libs/batched-merkle-tree/src/initialize_state_tree.rsprograms/system/src/accounts/init_context_account.rs
📚 Learning: 2025-10-16T06:33:19.426Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:19.426Z
Learning: Applies to program-libs/compressible/src/config.rs : Ensure serialization compatibility across Anchor, Pinocchio, and Borsh for core account types used by dependent programs
Applied to files:
program-libs/batched-merkle-tree/src/initialize_state_tree.rssdk-tests/sdk-token-test/tests/test.rsprograms/system/src/accounts/init_context_account.rssdk-tests/sdk-pinocchio-v1-test/tests/test.rs
📚 Learning: 2025-10-15T03:46:26.767Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/lib.rs : Load accounts according to type before check_forester: batched via BatchedMerkleTreeAccount::type_from_account_info(); regular via ctx.accounts.account.load()?.metadata; use custom deserialization when required.
Applied to files:
program-libs/batched-merkle-tree/src/initialize_state_tree.rsprograms/system/src/accounts/init_context_account.rssdk-tests/sdk-pinocchio-v1-test/tests/test.rs
📚 Learning: 2025-10-15T03:46:26.767Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/mod.rs : Export each new operation module by adding pub mod <operation>; and re-export with pub use <operation>::*.
Applied to files:
program-libs/batched-merkle-tree/src/initialize_state_tree.rsprograms/system/src/accounts/init_context_account.rs
📚 Learning: 2025-10-11T21:59:25.222Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-10-11T21:59:25.222Z
Learning: Applies to program-libs/account-checks/src/**/*.rs : On account initialization, call account_info_init to set the 8-byte discriminator
Applied to files:
program-libs/batched-merkle-tree/src/initialize_state_tree.rsprograms/system/src/accounts/init_context_account.rs
📚 Learning: 2025-10-11T21:59:25.222Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-10-11T21:59:25.222Z
Learning: Applies to program-libs/account-checks/src/!(account_info)/**/*.rs : Use AccountInfoTrait for runtime-agnostic account handling; avoid direct solana-program or pinocchio AccountInfo in general logic
Applied to files:
program-libs/batched-merkle-tree/src/initialize_state_tree.rssdk-tests/sdk-token-test/tests/test.rs
📚 Learning: 2025-10-11T21:59:25.222Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-10-11T21:59:25.222Z
Learning: Applies to program-libs/account-checks/src/account_info/account_info_trait.rs : Ensure the crate compiles with no features enabled by keeping trait definitions free of SDK-specific dependencies
Applied to files:
program-libs/batched-merkle-tree/src/initialize_state_tree.rssdk-tests/sdk-token-test/tests/test.rssdk-tests/sdk-pinocchio-v1-test/tests/test.rs
📚 Learning: 2025-10-15T03:46:26.767Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/*.rs : Each new operation module must define an Anchor context struct (e.g., NewOperationContext) with required accounts and a process_<operation> function that prepares signer seeds, maps accounts to the target program, and executes the CPI.
Applied to files:
program-libs/batched-merkle-tree/src/initialize_state_tree.rsprograms/system/src/accounts/init_context_account.rs
📚 Learning: 2025-10-15T03:46:26.767Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/lib.rs : Instruction handlers must compute work_units by operation type: batch operations use account.queue_batches.batch_size; single operations use DEFAULT_WORK_V1; custom operations compute based on complexity.
Applied to files:
program-libs/batched-merkle-tree/src/initialize_state_tree.rs
📚 Learning: 2025-10-15T03:46:43.242Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: sdk-tests/sdk-token-test/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:43.242Z
Learning: Run tests with: cargo test-sbf -p sdk-token-test --test <test-file-name>
Applied to files:
sdk-tests/sdk-token-test/tests/test.rssdk-tests/sdk-pinocchio-v1-test/tests/test.rs
📚 Learning: 2025-10-11T21:59:25.222Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-10-11T21:59:25.222Z
Learning: Applies to program-libs/account-checks/**/Cargo.toml : Define features solana, pinocchio, and test-only in Cargo.toml; default build should enable none
Applied to files:
sdk-tests/sdk-token-test/tests/test.rssdk-tests/sdk-pinocchio-v1-test/tests/test.rs
📚 Learning: 2025-10-15T03:46:43.242Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: sdk-tests/sdk-token-test/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:43.242Z
Learning: Applies to sdk-tests/sdk-token-test/**/tests/**/*.rs : Every test should only contain functional integration tests
Applied to files:
sdk-tests/sdk-token-test/tests/test.rs
📚 Learning: 2025-10-11T21:59:25.222Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-10-11T21:59:25.222Z
Learning: Applies to program-libs/account-checks/src/account_info/{solana.rs,pinocchio.rs,test_account_info.rs} : Gate SDK-specific implementations with #[cfg(feature = "solana"|"pinocchio"|"test-only")]
Applied to files:
sdk-tests/sdk-token-test/tests/test.rssdk-tests/sdk-pinocchio-v1-test/tests/test.rs
📚 Learning: 2025-10-11T21:59:25.222Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-10-11T21:59:25.222Z
Learning: Applies to program-libs/account-checks/src/account_info/test_account_info.rs : Use the mock AccountInfo implementation under the test-only feature for unit tests
Applied to files:
sdk-tests/sdk-token-test/tests/test.rssdk-tests/sdk-pinocchio-v1-test/tests/test.rs
📚 Learning: 2025-10-11T21:59:25.222Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-10-11T21:59:25.222Z
Learning: Applies to program-libs/account-checks/src/account_info/{solana.rs,pinocchio.rs,test_account_info.rs} : Provide SDK-specific AccountInfoTrait implementations in account_info/{solana.rs,pinocchio.rs,test_account_info.rs}
Applied to files:
sdk-tests/sdk-token-test/tests/test.rssdk-tests/sdk-pinocchio-v1-test/tests/test.rs
📚 Learning: 2025-10-16T06:33:55.362Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:55.362Z
Learning: Applies to programs/compressed-token/program/src/create_token_account.rs : Create Token Account instruction must validate that the config state is ACTIVE only
Applied to files:
sdk-tests/sdk-token-test/tests/test.rs
📚 Learning: 2025-10-16T06:33:55.362Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:55.362Z
Learning: Applies to programs/compressed-token/program/src/create_associated_token_account.rs : Create Associated Token Account instruction must validate that the config state is ACTIVE only
Applied to files:
sdk-tests/sdk-token-test/tests/test.rs
📚 Learning: 2025-10-11T21:59:25.222Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-10-11T21:59:25.222Z
Learning: Applies to program-libs/account-checks/src/**/*.rs : Validate account type with 8-byte discriminators using check_discriminator before deserialization
Applied to files:
sdk-tests/sdk-token-test/tests/test.rsprograms/system/src/accounts/init_context_account.rssdk-tests/sdk-pinocchio-v1-test/tests/test.rs
📚 Learning: 2025-10-11T21:59:25.222Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-10-11T21:59:25.222Z
Learning: Applies to program-libs/account-checks/src/checks.rs : Expose and maintain account validation helpers (check_owner, check_program, check_mut/non_mut, check_signer, check_discriminator, set_discriminator, check_pda_seeds, check_account_balance_is_rent_exempt, account_info_init) in checks.rs
Applied to files:
programs/system/src/accounts/init_context_account.rs
📚 Learning: 2025-10-11T21:59:25.222Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-10-11T21:59:25.222Z
Learning: Applies to program-libs/account-checks/src/packed_accounts.rs : For dynamic account sets, use PackedAccounts for index-based access with bounds checks instead of manual indexing
Applied to files:
programs/system/src/accounts/init_context_account.rssdk-tests/sdk-pinocchio-v1-test/tests/test.rs
📚 Learning: 2025-10-11T21:59:25.222Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-10-11T21:59:25.222Z
Learning: Applies to program-libs/account-checks/src/discriminator.rs : Define and keep discriminator constants and the Discriminator trait in discriminator.rs for compile-time verification
Applied to files:
programs/system/src/accounts/init_context_account.rs
📚 Learning: 2025-10-11T21:59:52.712Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/docs/CLAUDE.md:0-0
Timestamp: 2025-10-11T21:59:52.712Z
Learning: Applies to program-libs/account-checks/docs/**/DISCRIMINATOR.md : DISCRIMINATOR.md must document 8-byte discriminators, the Discriminator trait, constant arrays for compile-time checks, and integration with account initialization
Applied to files:
programs/system/src/accounts/init_context_account.rs
📚 Learning: 2025-10-11T21:59:25.222Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-10-11T21:59:25.222Z
Learning: Applies to program-libs/account-checks/src/error.rs : Maintain stable mapping of AccountError to ProgramError, including Pinocchio code mapping (1–11), in error.rs
Applied to files:
programs/system/src/accounts/init_context_account.rs
📚 Learning: 2025-10-11T21:59:25.222Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-10-11T21:59:25.222Z
Learning: Applies to program-libs/account-checks/src/account_iterator.rs : Use AccountIterator for sequential account retrieval to get precise file:line:column error locations; avoid manual index handling
Applied to files:
programs/system/src/accounts/init_context_account.rs
📚 Learning: 2025-10-16T06:33:19.426Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:19.426Z
Learning: Applies to program-libs/compressible/src/config.rs : Maintain CompressibleConfig account structure with Anchor/Borsh/Pod (Pinocchio/Pod) serialization and related state validation methods (validate_active, validate_not_inactive) in src/config.rs
Applied to files:
sdk-tests/sdk-pinocchio-v1-test/tests/test.rs
🧬 Code graph analysis (1)
programs/system/src/accounts/init_context_account.rs (1)
program-libs/account-checks/src/checks.rs (1)
check_owner(135-143)
⏰ 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). (21)
- GitHub Check: stateless-js-v2
- GitHub Check: stateless-js-v1
- GitHub Check: lint
- GitHub Check: Test program-libs-slow
- GitHub Check: Test batched-merkle-tree-simulate
- GitHub Check: Test program-libs-fast
- GitHub Check: cli-v2
- GitHub Check: programs (system-cpi-test-v2-functional-account-infos, ["cargo-test-sbf -p system-cpi-v2-test -- ...
- GitHub Check: programs (light-system-program-compression, ["cargo-test-sbf -p system-test -- test_with_compress...
- GitHub Check: programs (system-cpi-test-v2-functional-read-only, ["cargo-test-sbf -p system-cpi-v2-test -- func...
- GitHub Check: programs (system-cpi-test, ["cargo-test-sbf -p system-cpi-test", "cargo test -p light-system-prog...
- GitHub Check: programs (compressed-token-and-e2e, ["cargo-test-sbf -p compressed-token-test --test v1", "cargo-...
- GitHub Check: programs (account-compression-and-registry, ["cargo-test-sbf -p account-compression-test", "cargo...
- GitHub Check: programs (compressed-token-batched-tree, ["cargo-test-sbf -p compressed-token-test -- test_transf...
- GitHub Check: programs (light-system-program-address, ["cargo-test-sbf -p system-test -- test_with_address", "c...
- GitHub Check: cli-v1
- GitHub Check: system-programs (anchor & pinocchio, ["cargo-test-sbf -p sdk-anchor-test", "cargo-test-sbf -p sdk...
- GitHub Check: Forester e2e test
- GitHub Check: system-programs (token test, ["cargo-test-sbf -p sdk-token-test"])
- GitHub Check: system-programs (native, ["cargo-test-sbf -p sdk-native-test", "cargo-test-sbf -p sdk-v1-native-t...
- GitHub Check: system-programs (sdk-libs, light-sdk-macros light-sdk light-program-test light-client light-compr...
🔇 Additional comments (8)
sdk-tests/sdk-pinocchio-v1-test/tests/test.rs (1)
1-1: LGTM! Test-sbf feature gate enabled correctly.The conditional compilation attribute is now active, allowing these tests to run with
cargo test-sbf.sdk-tests/sdk-token-test/tests/test.rs (1)
1-1: LGTM! Test-sbf feature gate enabled correctly.The conditional compilation attribute is now active, consistent with the other SDK test modules in this PR.
programs/registry/src/protocol_config/state.rs (2)
60-60: Default CPI context size updated to V2.The default
cpi_context_sizehas been correctly updated to 14020 bytes, aligning with the PR objective to reduce the CPI context account size.
83-83: Verify testnet_default keeping the old CPI context size is intentional.The
testnet_default()function retains the old size of 20488 bytes while the standarddefault()uses the new 14020 bytes. This creates a divergence between environments that could lead to confusion or compatibility issues.Please confirm:
- Is this intentional for backwards compatibility with existing testnet deployments?
- Are there migration plans for testnet to adopt the new V2 size?
- Could this divergence cause issues with code that expects consistent CPI context sizes across environments?
program-libs/batched-merkle-tree/src/initialize_state_tree.rs (1)
11-11: LGTM: Consistent migration to V2 CPI context size constant.All usages of the CPI context size have been consistently updated to use
DEFAULT_CPI_CONTEXT_ACCOUNT_SIZE_V2, including the default implementation and all test utilities. This ensures uniform behavior across initialization paths.Also applies to: 50-50, 297-297, 317-317, 337-337
programs/system/src/accounts/init_context_account.rs (3)
6-8: LGTM: Import updated for V2 constant.The import correctly includes
DEFAULT_CPI_CONTEXT_ACCOUNT_SIZE_V2alongsideBatchedMerkleTreeAccount, supporting the new resize logic.
77-78: Good: Owner check added before realloc.Adding the owner check before any modification operations prevents unauthorized accounts from reinitializing the CPI context account, which is a critical security improvement.
88-89: All realloc concerns are verified and correctly implemented.The code properly handles the account size reduction:
Size reduction is handled correctly: The associated_merkle_tree is read before resizing (lines 80-86), then the account is resized to 14020 bytes (line 89), and reinitialized with the preserved value (lines 91-93).
Essential data fits within 14020 bytes: The test assertion at line 133 confirms that after reinitialization, remaining_capacity() == 6500, verifying all required data is properly allocated and the structure deserializes correctly.
Remaining capacity calculation is correct: The constants show V1 size was 20488 bytes and V2 is 14020 bytes. The test explicitly validates that the remaining capacity equals 6500 bytes as per PR objectives, confirming the overhead calculation accounts for all metadata properly.
SwenSchaeferjohann
left a comment
There was a problem hiding this comment.
just one comment
668d75e to
31f07f9
Compare
… context account test
31f07f9 to
4da1aaa
Compare
… context account test (#2034)
Changes:
14020bytes from 20kbContext:
12,968bytes remaining capacity for output account data12,968bytes is greater than the light system program -> account compression program cpi can hold which is a footgun14020bytes we reduce the remaining capacity to6,500that should work in most cases.30output accounts with max6,500bytes account data eg216bytes per compressed account, or a number of smaller and bigger compressed accountsSummary by CodeRabbit
New Features
Bug Fixes
Chores