Skip to content

Conversation

@AvhiMaz
Copy link

@AvhiMaz AvhiMaz commented Nov 14, 2025

Replace the precompiled dlp.so binary with a production version compiled without
the unit_test_config feature, which hardcoded test validator authorities. Update
integration tests and test programs to accept and properly pass custom validator
identities instead of relying on hardcoded test values.

Fixes #602

Summary by CodeRabbit

  • New Features

    • Optional validator identity support added to delegation and escrow initialization flows; test call sites updated to pass an optional validator.
  • Deprecations

    • Legacy test authority helper marked deprecated; prefer the new validator-authority helper.
  • Bug Fixes

    • Improved test error handling to gracefully handle temporary undelegation (InvalidWritableAccount).
  • Chores

    • Suppressed deprecation warnings in several test modules for cleaner builds.

…nfig (magicblock-labs#602)

  Replace the precompiled dlp.so binary with a production version compiled without
  the unit_test_config feature, which hardcoded test validator authorities. Update
  integration tests and test programs to accept and properly pass custom validator
  identities instead of relying on hardcoded test values.

  Fixes magicblock-labs#602

Signed-off-by: AvhiMaz <[email protected]>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 14, 2025

Walkthrough

Propagate an optional validator identity through delegate-related instruction builders and handlers: add validator-aware instruction APIs, thread an Option into delegate handler/config, update client and tests to pass validator where applicable, deprecate a legacy test utility, and silence deprecated warnings in several test modules.

Changes

Cohort / File(s) Summary
Flexi-counter instruction & handler
test-integration/programs/flexi-counter/src/instruction.rs, test-integration/programs/flexi-counter/src/processor/call_handler.rs
Added pub fn create_delegate_ix_with_validator(payer: Pubkey, _validator: Option<Pubkey>) -> Instruction and extended process_redelegation_call_handler to accept validator: Option<Pubkey> and propagate it into DelegateConfig.
Schedulecommit API
test-integration/programs/schedulecommit/src/api.rs
Added init_payer_escrow_with_validator(payer: Pubkey, validator: Option<Pubkey>) -> [Instruction; 2]; init_payer_escrow delegates to it with None; validator propagated into DelegateEphemeralBalanceArgs.
Client context & test call sites
test-integration/schedulecommit/client/src/schedule_commit_context.rs, test-integration/test-schedule-intent/tests/test_schedule_intents.rs
Replaced calls to validator-less initializers/instructions with validator-aware variants, passing ephemeral validator identity through escrow/delegate flows; updated delegate call sites to use create_delegate_ix_with_validator.
Test runtime error handling
test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs
Added short-circuit handling for TransactionError::InvalidWritableAccount on simulate and execute error paths to avoid test failures when account is temporarily undelegated.
Deprecation suppressions in tests
test-integration/test-config/tests/auto_airdrop_feepayer.rs, test-integration/test-ledger-restore/tests/06_delegated_account.rs, test-integration/test-magicblock-api/tests/test_claim_fees.rs, test-integration/test-runner/bin/run_tests.rs, test-integration/test-task-scheduler/src/lib.rs
Added crate-level #![allow(deprecated)] attributes to suppress deprecation warnings in those test modules.
Deprecated test utility
test-integration/test-tools/src/loaded_accounts.rs
Marked with_delegation_program_test_authority() as #[deprecated(...)] with a doc note pointing to new_with_new_validator_authority(); signature unchanged.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Test as Test code
    participant Client as schedule_commit_context
    participant API as schedulecommit::api
    participant CPI as flexi-counter CPI

    rect rgb(235,245,255)
    Test->>Client: request escrow for payer (includes ephem validator)
    Client->>API: init_payer_escrow_with_validator(payer, Some(validator))
    end

    rect rgb(245,255,235)
    API->>API: build top_up + delegate instructions (passes validator)
    API->>CPI: create_delegate_ix_with_validator(payer, Some(validator))
    end

    rect rgb(255,245,235)
    CPI->>CPI: delegate handler receives validator\nand initializes DelegateConfig { validator }
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

  • Pay attention to correct propagation and usage of Option (None vs Some) across API → client → CPI.
  • Verify process_redelegation_call_handler uses the passed validator where intended.
  • Validate test early-return logic for TransactionError::InvalidWritableAccount.
  • Confirm deprecation attribute and doc note text in loaded_accounts.rs.

Possibly related PRs

Suggested reviewers

  • thlorenz
  • Dodecahedr0x
  • GabrielePicco

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
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 (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main objective: migrating integration tests to use a production DLP build without the unit_test_config feature.
Linked Issues check ✅ Passed The PR successfully addresses issue #602 by replacing the test DLP binary with production version and updating tests to accept custom validator identities instead of hardcoded values.
Out of Scope Changes check ✅ Passed All changes are within scope: new validator-accepting functions, updated test code to pass validator identities, and deprecation markers for old test-only code.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 97cfa2e and 80532bd.

📒 Files selected for processing (2)
  • test-integration/schedulecommit/client/src/schedule_commit_context.rs (2 hunks)
  • test-integration/test-schedule-intent/tests/test_schedule_intents.rs (3 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-10-14T09:56:14.047Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 564
File: test-integration/programs/flexi-counter/src/processor/call_handler.rs:122-125
Timestamp: 2025-10-14T09:56:14.047Z
Learning: The file test-integration/programs/flexi-counter/src/processor/call_handler.rs contains a test smart contract used for integration testing, not production code.

Applied to files:

  • test-integration/test-schedule-intent/tests/test_schedule_intents.rs
🧬 Code graph analysis (2)
test-integration/test-schedule-intent/tests/test_schedule_intents.rs (1)
test-integration/programs/flexi-counter/src/instruction.rs (4)
  • create_add_ix (226-238)
  • create_delegate_ix_with_validator (303-308)
  • create_init_ix (189-202)
  • create_intent_ix (381-422)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (1)
test-integration/programs/schedulecommit/src/api.rs (2)
  • init_payer_escrow_with_validator (39-63)
  • pda_and_bump (263-267)
🔇 Additional comments (3)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (1)

199-204: LGTM! Validator identity properly propagated to escrow initialization.

The change correctly extracts the validator identity from the context and passes it to the validator-aware escrow initializer. The use of .as_ref().copied() appropriately handles the Option<Pubkey> type.

test-integration/test-schedule-intent/tests/test_schedule_intents.rs (2)

292-315: LGTM! Escrow index consistency maintained and validator properly propagated.

The escrow setup now consistently uses index 1 for both the top-up and delegation instructions, and the validator identity is correctly passed through DelegateArgs. This addresses the escrow index mismatch flagged in previous reviews.


354-357: LGTM! Validator-aware delegation API properly utilized.

The switch to create_delegate_ix_with_validator with the ephemeral validator identity maintains consistency with the broader pattern of propagating validator identities through delegation flows. While the current implementation ignores the validator parameter (as noted by the _validator prefix), the API is correctly structured for future use.


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

Actionable comments posted: 3

♻️ Duplicate comments (4)
test-integration/test-ledger-restore/tests/06_delegated_account.rs (1)

1-2: Deprecation warning suppression.

Same deprecation suppression pattern as noted in test-integration/test-config/tests/auto_airdrop_feepayer.rs. See the comment on that file regarding verification of deprecated APIs.

test-integration/test-runner/bin/run_tests.rs (1)

1-2: Deprecation warning suppression.

Same deprecation suppression pattern. See the verification request in test-integration/test-config/tests/auto_airdrop_feepayer.rs.

test-integration/test-magicblock-api/tests/test_claim_fees.rs (1)

1-2: Deprecation warning suppression.

Same deprecation suppression pattern. See the verification request in test-integration/test-config/tests/auto_airdrop_feepayer.rs.

test-integration/test-task-scheduler/src/lib.rs (1)

1-2: Deprecation warning suppression.

Same deprecation suppression pattern. See the verification request in test-integration/test-config/tests/auto_airdrop_feepayer.rs.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ded9c50 and 0909b8f.

⛔ Files ignored due to path filters (1)
  • test-integration/schedulecommit/elfs/dlp.so is excluded by !**/*.so
📒 Files selected for processing (12)
  • test-integration/programs/flexi-counter/src/instruction.rs (1 hunks)
  • test-integration/programs/flexi-counter/src/processor/call_handler.rs (2 hunks)
  • test-integration/programs/schedulecommit/src/api.rs (2 hunks)
  • test-integration/schedulecommit/client/src/schedule_commit_context.rs (2 hunks)
  • test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (1 hunks)
  • test-integration/test-config/tests/auto_airdrop_feepayer.rs (1 hunks)
  • test-integration/test-ledger-restore/tests/06_delegated_account.rs (1 hunks)
  • test-integration/test-magicblock-api/tests/test_claim_fees.rs (1 hunks)
  • test-integration/test-runner/bin/run_tests.rs (1 hunks)
  • test-integration/test-schedule-intent/tests/test_schedule_intents.rs (3 hunks)
  • test-integration/test-task-scheduler/src/lib.rs (1 hunks)
  • test-integration/test-tools/src/loaded_accounts.rs (1 hunks)
🧰 Additional context used
🧠 Learnings (4)
📚 Learning: 2025-10-14T09:56:14.047Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 564
File: test-integration/programs/flexi-counter/src/processor/call_handler.rs:122-125
Timestamp: 2025-10-14T09:56:14.047Z
Learning: The file test-integration/programs/flexi-counter/src/processor/call_handler.rs contains a test smart contract used for integration testing, not production code.

Applied to files:

  • test-integration/programs/flexi-counter/src/instruction.rs
  • test-integration/programs/flexi-counter/src/processor/call_handler.rs
  • test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs
  • test-integration/test-task-scheduler/src/lib.rs
  • test-integration/test-config/tests/auto_airdrop_feepayer.rs
  • test-integration/test-schedule-intent/tests/test_schedule_intents.rs
📚 Learning: 2025-10-21T14:00:54.642Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/websocket/account_subscribe.rs:18-27
Timestamp: 2025-10-21T14:00:54.642Z
Learning: In magicblock-aperture account_subscribe handler (src/requests/websocket/account_subscribe.rs), the RpcAccountInfoConfig fields data_slice, commitment, and min_context_slot are currently ignored—only encoding is applied. This is tracked as technical debt in issue #579: https://github.com/magicblock-labs/magicblock-validator/issues/579

Applied to files:

  • test-integration/test-ledger-restore/tests/06_delegated_account.rs
  • test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs
  • test-integration/test-config/tests/auto_airdrop_feepayer.rs
📚 Learning: 2025-11-07T13:09:52.253Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: test-kit/src/lib.rs:275-0
Timestamp: 2025-11-07T13:09:52.253Z
Learning: In test-kit, the transaction scheduler in ExecutionTestEnv is not expected to shut down during tests. Therefore, using `.unwrap()` in test helper methods like `schedule_transaction` is acceptable and will not cause issues in the test environment.

Applied to files:

  • test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs
📚 Learning: 2025-11-07T18:19:48.996Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 614
File: test-integration/programs/schedulecommit/Cargo.toml:19-20
Timestamp: 2025-11-07T18:19:48.996Z
Learning: In Solana programs (crates depending on solana-program), the empty feature flags `custom-heap = []` and `custom-panic = []` are standard declarations required to avoid compiler warnings. These should not be flagged as unused features in Cargo.toml files for Solana program crates.

Applied to files:

  • test-integration/test-task-scheduler/src/lib.rs
  • test-integration/test-runner/bin/run_tests.rs
  • test-integration/test-magicblock-api/tests/test_claim_fees.rs
🧬 Code graph analysis (2)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (1)
test-integration/programs/schedulecommit/src/api.rs (2)
  • init_payer_escrow_with_validator (39-63)
  • pda_and_bump (263-267)
test-integration/test-schedule-intent/tests/test_schedule_intents.rs (1)
test-integration/programs/flexi-counter/src/instruction.rs (1)
  • create_delegate_ix_with_validator (303-308)
🔇 Additional comments (7)
test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (2)

233-235: Early return on InvalidWritableAccount in simulation is appropriate.

The early return when detecting InvalidWritableAccount in the simulation result correctly handles the transient undelegation state. However, note that string matching on error messages can be fragile if error message formats change.


247-252: LGTM! Proper error handling for undelegated accounts.

The structured error matching using matches! correctly identifies the InvalidWritableAccount error and returns early, preventing false test failures when accounts are in a transient undelegated state. This is an improvement over the string-based check in the simulation path above.

test-integration/programs/flexi-counter/src/processor/call_handler.rs (1)

100-103: LGTM! Validator parameter properly threaded for future use.

The addition of the validator parameter to process_redelegation_call_handler and its propagation to DelegateConfig aligns with the PR's goal of supporting custom validator identities. While this function is currently dead code due to Solana's reentrancy restrictions, the change prepares the infrastructure for validator-aware delegation when reentrancy becomes possible.

Also applies to: 130-133

test-integration/programs/flexi-counter/src/instruction.rs (1)

303-308: Transitional API: validator parameter currently unused.

This new function accepts a validator parameter but doesn't utilize it—it simply delegates to the existing create_delegate_ix. This is a reasonable transitional step to establish the API signature while the underlying implementation is being updated. However, consider:

  1. Documenting when and how the validator parameter will be used
  2. Adding a TODO or tracking issue reference for the full implementation
  3. Considering whether to mark this as #[deprecated] once the parameter is actually utilized in a new version

Is there a tracking issue or timeline for when the validator parameter will be actively used rather than ignored?

test-integration/test-config/tests/auto_airdrop_feepayer.rs (1)

1-2: The deprecated API suppression is justified and documented.

The #![allow(deprecated)] suppresses warnings from LoadedAccounts::with_delegation_program_test_authority() (line 49), which is marked deprecated in test-integration/test-tools/src/loaded_accounts.rs. The deprecation is well-documented:

  • Migration path: Use new_with_new_validator_authority() instead
  • Reason: DLP now uses production build without unit_test_config (issue-602)

The current code uses the deprecated method intentionally for backward compatibility with existing test infrastructure. Consider updating to the new API when convenient, though the current approach is acceptable for test code during a transition period.

test-integration/schedulecommit/client/src/schedule_commit_context.rs (1)

8-9: Validator-aware escrow wiring looks correct

Switching to init_payer_escrow_with_validator and deriving validator_identity from common_ctx.ephem_validator_identity.as_ref().copied() cleanly threads the optional validator without changing behavior when it’s None. No issues found with the new escrow flow.

Also applies to: 198-207

test-integration/programs/schedulecommit/src/api.rs (1)

35-37: New escrow helper cleanly propagates optional validator

init_payer_escrow_with_validator centralizes the escrow setup while init_payer_escrow remains a backward-compatible wrapper passing None. Wiring the validator parameter straight into DelegateArgs is consistent with the DLP API and matches the intent to move off hardcoded test authorities.

Also applies to: 39-42, 52-58

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.

Actionable comments posted: 1

♻️ Duplicate comments (1)
test-integration/test-schedule-intent/tests/test_schedule_intents.rs (1)

350-351: Consistent validator-aware delegation usage.

The update to create_delegate_ix_with_validator passing ctx.ephem_validator_identity is consistent with the new validator-aware delegation flow and matches the pattern established in setup_payer. This keeps all delegation call sites aligned with the PR objective.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0909b8f and 375da28.

📒 Files selected for processing (2)
  • test-integration/test-schedule-intent/tests/test_schedule_intents.rs (3 hunks)
  • test-integration/test-tools/src/loaded_accounts.rs (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-10-14T09:56:14.047Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 564
File: test-integration/programs/flexi-counter/src/processor/call_handler.rs:122-125
Timestamp: 2025-10-14T09:56:14.047Z
Learning: The file test-integration/programs/flexi-counter/src/processor/call_handler.rs contains a test smart contract used for integration testing, not production code.

Applied to files:

  • test-integration/test-schedule-intent/tests/test_schedule_intents.rs
🧬 Code graph analysis (1)
test-integration/test-schedule-intent/tests/test_schedule_intents.rs (1)
test-integration/programs/flexi-counter/src/instruction.rs (4)
  • create_add_ix (226-238)
  • create_delegate_ix_with_validator (303-308)
  • create_init_ix (189-202)
  • create_intent_ix (381-422)
🔇 Additional comments (2)
test-integration/test-schedule-intent/tests/test_schedule_intents.rs (2)

7-8: LGTM: Import updated for validator-aware delegation.

The import change from create_delegate_ix to create_delegate_ix_with_validator correctly reflects the new validator-aware delegation API, aligning with the PR objective to pass explicit validator identities instead of relying on hardcoded test values.


291-311: Excellent fix: Index consistency issue resolved and validator identity properly propagated.

The previous critical issue regarding index mismatch has been addressed. The code now consistently uses index 1 for:

  • top_up_ephemeral_balance (line 296)
  • delegate_ephemeral_balance (line 302)
  • PDA assertion (line 314)

The explicit validator identity propagation via ctx.ephem_validator_identity (line 306) correctly implements the PR objective to move away from hardcoded test validator authorities. The two-step delegation (top-up followed by delegate) is sent atomically in a single transaction (line 310), preventing any intermediate failure states.

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.

Validator's integration tests shall use prod version of dlp instead of unit_test_confg one

1 participant