Skip to content

make validator account optional in delegate_permission instruction - #203

Open
dhruvja wants to merge 2 commits into
magicblock-labs:mainfrom
dhruvja:dhruvja/optional-validator-acc
Open

make validator account optional in delegate_permission instruction#203
dhruvja wants to merge 2 commits into
magicblock-labs:mainfrom
dhruvja:dhruvja/optional-validator-acc

Conversation

@dhruvja

@dhruvja dhruvja commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

The delegate_permission instruction has the validator account as optional but the DelegatePermission struct enforces to have passed the validator key.

Summary by CodeRabbit

  • Bug Fixes

    • The validator parameter in permission delegation operations is now optional, providing greater flexibility in delegation workflows.
  • Tests

    • Added test coverage for permission delegation without a specified validator.

@coderabbitai

coderabbitai Bot commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@dhruvja has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 46 minutes and 55 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 46 minutes and 55 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 30827a69-3cb7-49a1-b8dc-a6abbb59bc49

📥 Commits

Reviewing files that changed from the base of the PR and between 6a9ab3d and f6cac5e.

📒 Files selected for processing (2)
  • rust/pinocchio/src/acl/instruction/delegate_permission.rs
  • rust/tests/access_control_test.rs
📝 Walkthrough

Walkthrough

The validator field in the DelegatePermission struct is changed from a required Pubkey to Option<Pubkey>. Instruction account construction now conditionally includes the validator AccountMeta only when the validator is present. The builder implementations (DelegatePermissionBuilder and DelegatePermissionCpiBuilder) have been updated to propagate the optional validator value instead of unwrapping, removing assumptions about its presence. A test case has been added to verify the builder behavior when no validator is provided.

Suggested reviewers

  • Dodecahedr0x
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@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 the current code and only fix it if needed.

Inline comments:
In `@rust/tests/access_control_test.rs`:
- Around line 160-193: Add a companion test that exercises the Some(validator)
branch: create unique Pubkey values like in
test_delegate_permission_builder_without_validator, set
builder.validator(Some(validator_pubkey)), call builder.instruction() (or
instruction_with_remaining_accounts() if used), and assert
instruction.program_id == PERMISSION_PROGRAM_ID, instruction.accounts.len() ==
11, instruction.accounts[0].pubkey == payer, and that the validator_pubkey
appears at instruction.accounts[10].pubkey to pin the extra-account ordering for
the Some branch of DelegatePermissionBuilder.
🪄 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: 180a0947-e100-4fb4-a101-a052c5edc370

📥 Commits

Reviewing files that changed from the base of the PR and between 059484a and 6a9ab3d.

📒 Files selected for processing (2)
  • rust/sdk/src/access_control/instructions/delegate_permission.rs
  • rust/tests/access_control_test.rs

Comment thread rust/tests/access_control_test.rs
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