Skip to content

feat: Support validator-requested undelegation in DLP finalize paths#1391

Closed
snawaz wants to merge 1 commit into
snawaz/backfill-reqfrom
snawaz/validator-finalize-undelegate
Closed

feat: Support validator-requested undelegation in DLP finalize paths#1391
snawaz wants to merge 1 commit into
snawaz/backfill-reqfrom
snawaz/validator-finalize-undelegate

Conversation

@snawaz

@snawaz snawaz commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Breaking Changes

  • None
  • Yes — migration path described below

Test Plan

Summary by CodeRabbit

  • Bug Fixes

    • Improved undelegation handling so finalize flows no longer add a separate undelegation step when one isn’t needed.
    • Refined task scheduling to keep post-undelegation actions in the correct order.
  • Documentation

    • Clarified finalize and undelegation behavior in the service and validator specs.
    • Updated guidance around auto-undelegation, request handling, and rent repayment.
  • Tests

    • Expanded coverage for finalize and commit-finalize task behavior, including account expectations and optimized task counts.

snawaz commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

This PR removes explicit UndelegateTask generation from CommitAndUndelegate and CommitFinalizeAndUndelegate flows in the committor service's task builder, relying instead on DLP's auto-undelegation behavior embedded in FinalizeTask/CommitFinalizeTask. A new helper generates only post-undelegate base action tasks. Tests are added/updated to verify auto-undelegation accounts and revised task expectations. The magicblock-delegation-program-api dependency revision is bumped in both root and test-integration Cargo.toml. Documentation and spec files are updated to describe the new behavior.

Sequence Diagram(s)

Not applicable — changes are primarily internal logic restructuring, dependency version bumps, and documentation updates rather than new user-facing interaction flows.

Suggested reviewers: GabrielePicco, taco-paco

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch snawaz/validator-finalize-undelegate

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@magicblock-committor-service/src/tasks/task_builder.rs`:
- Around line 445-449: Add direct test coverage for the
`commit_finalize_and_undelegate` path in `finalize_tasks()` so the wiring to
`create_post_undelegate_action_tasks` is exercised, not just
`CommitFinalizeTask::instruction()` account layout. Add a test in the same area
as `finalize_tasks`/`task_builder` that builds an intent bundle with
`commit_bundle.commit_finalize_and_undelegate`, calls `finalize_tasks()`, and
asserts the returned tasks include the expected post-undelegate BaseAction
ordering. Use the existing `create_post_undelegate_action_tasks`,
`finalize_tasks`, and `commit_finalize_and_undelegate` symbols to locate the
branch and verify it behaves like the `commit_and_undelegate` coverage.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: bb5c68be-7594-4d83-9c8d-e4ca56964b60

📥 Commits

Reviewing files that changed from the base of the PR and between 297031f and eed8284.

⛔ Files ignored due to path filters (3)
  • Cargo.lock is excluded by !**/*.lock
  • test-integration/Cargo.lock is excluded by !**/*.lock
  • test-integration/schedulecommit/elfs/dlp.so is excluded by !**/*.so
📒 Files selected for processing (7)
  • .agents/context/crates/magicblock-committor-service.md
  • .agents/specs/validator-specification.md
  • Cargo.toml
  • magicblock-committor-service/src/tasks/mod.rs
  • magicblock-committor-service/src/tasks/task_builder.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
  • test-integration/Cargo.toml

Comment on lines 445 to 449
if let Some(ref value) =
intent_bundle.intent_bundle.commit_finalize_and_undelegate
{
tasks.extend(create_undelegate_tasks(value, &delegation_metadata)?);
tasks.extend(create_post_undelegate_action_tasks(value));
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add direct test coverage for commit_finalize_and_undelegate in finalize_tasks.

task_strategist.rs gained tests for commit_and_undelegate (auto-undelegate + post-undelegate BaseAction ordering), but no equivalent test exercises this commit_finalize_and_undelegate branch through finalize_tasks() to confirm create_post_undelegate_action_tasks output for it. The mod.rs tests only cover CommitFinalizeTask::instruction() account layout, not this wiring path.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@magicblock-committor-service/src/tasks/task_builder.rs` around lines 445 -
449, Add direct test coverage for the `commit_finalize_and_undelegate` path in
`finalize_tasks()` so the wiring to `create_post_undelegate_action_tasks` is
exercised, not just `CommitFinalizeTask::instruction()` account layout. Add a
test in the same area as `finalize_tasks`/`task_builder` that builds an intent
bundle with `commit_bundle.commit_finalize_and_undelegate`, calls
`finalize_tasks()`, and asserts the returned tasks include the expected
post-undelegate BaseAction ordering. Use the existing
`create_post_undelegate_action_tasks`, `finalize_tasks`, and
`commit_finalize_and_undelegate` symbols to locate the branch and verify it
behaves like the `commit_and_undelegate` coverage.

@snawaz

snawaz commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

discarded because the idea of undelegation in finalize step is discarded.

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.

1 participant