Skip to content

Comments

fix: system program addresses#2298

Merged
SwenSchaeferjohann merged 3 commits intomainfrom
jorrit/fix-system-program-addresses
Feb 18, 2026
Merged

fix: system program addresses#2298
SwenSchaeferjohann merged 3 commits intomainfrom
jorrit/fix-system-program-addresses

Conversation

@ananas-block
Copy link
Contributor

@ananas-block ananas-block commented Feb 18, 2026

Summary by CodeRabbit

  • New Features

    • Added support for a new instruction variant controlled by the "reinit" feature flag.
  • Refactor

    • Simplified internal address matching logic for improved clarity.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 18, 2026

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • program-tests/system-test/tests/v2_failing_tests.rs is excluded by none and included by none

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR introduces a feature-gated enum variant ReInitCpiContextAccount to the instruction discriminator and refactors an iterator pattern in the CPI data processor to use a more direct matching approach, reducing intermediate complexity while preserving existing behavior.

Changes

Cohort / File(s) Summary
Feature-gated Instruction Variant
programs/system/src/lib.rs
Added ReInitCpiContextAccount enum variant to InstructionDiscriminator, conditionally compiled behind the "reinit" feature flag with corresponding cfg-guarded match handling.
Iterator Pattern Simplification
programs/system/src/processor/create_outputs_cpi_data.rs
Refactored address lookup logic from chained iter().filter().position() with nested unwrap() to a single iter().position() with direct Some(address) matching. Preserves functionality while improving readability.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

ai-review

Suggested reviewers

  • sergeytimoshin
  • SwenSchaeferjohann

Poem

A variant awakens behind the feature gate, 🔐
While iterators find a cleaner state,
Direct and precise, no unwrap delays,
Small steps forward, paving better ways. ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'fix: system program addresses' is vague and generic, lacking specificity about what addresses are being fixed or how they relate to the actual changes. Make the title more specific by describing the actual change, such as 'fix: simplify address check in create_outputs_cpi_data' or 'fix: add ReInitCpiContextAccount variant with feature flag'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 70.00%.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch jorrit/fix-system-program-addresses

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.

Entire-Checkpoint: 5a3de7e68923
Copy link
Contributor

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
programs/system/src/lib.rs (1)

50-58: 🧹 Nitpick | 🔵 Trivial

InstructionDiscriminator should be #[non_exhaustive] when it has cfg-gated variants.

Since InstructionDiscriminator is pub and has a variant that only exists under #[cfg(feature = "reinit")], any downstream exhaustive match on this type will fail to compile depending on which features are active. Marking the enum #[non_exhaustive] prevents this class of breakage.

♻️ Proposed fix
+#[non_exhaustive]
 pub enum InstructionDiscriminator {
     InitializeCpiContextAccount,
     Invoke,
     InvokeCpi,
     InvokeCpiWithReadOnly,
     InvokeCpiWithAccountInfo,
     #[cfg(feature = "reinit")]
     ReInitCpiContextAccount,
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@programs/system/src/lib.rs` around lines 50 - 58, The public enum
InstructionDiscriminator contains a cfg-gated variant (ReInitCpiContextAccount)
which can cause downstream exhaustive matches to break; add the
#[non_exhaustive] attribute above the pub enum InstructionDiscriminator
declaration so external code cannot exhaustively pattern-match it and
future/feature-gated variants won't break consumers (no other code changes
required besides annotating the enum).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@programs/system/src/lib.rs`:
- Around line 50-58: The public enum InstructionDiscriminator contains a
cfg-gated variant (ReInitCpiContextAccount) which can cause downstream
exhaustive matches to break; add the #[non_exhaustive] attribute above the pub
enum InstructionDiscriminator declaration so external code cannot exhaustively
pattern-match it and future/feature-gated variants won't break consumers (no
other code changes required besides annotating the enum).

@SwenSchaeferjohann SwenSchaeferjohann merged commit b2d4fc1 into main Feb 18, 2026
33 checks passed
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