perf: ctoken remove return value of verify_owner_or_delegate_signer#2022
Conversation
WalkthroughThe function Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
programs/compressed-token/program/src/shared/owner_validation.rs (1)
8-10: Docstring is stale after signature change; update to match Result<(), ProgramError>.The comment still says it returns the delegate AccountInfo. It no longer does. Please update for accuracy.
-/// Verify owner or delegate signer authorization for token operations -/// Returns the delegate account info if delegate is used, None otherwise +/// Verify owner or delegate signer authorization for token operations. +/// Succeeds if either the delegate (when provided) or the owner is a signer. +/// Returns Ok(()) on success.This helper continues to build on centralized signer checks from light_account_checks, which is consistent with keeping validation helpers unified. Based on learnings.
Also applies to: 14-14
🧹 Nitpick comments (1)
programs/compressed-token/program/src/shared/token_input.rs (1)
121-123: Confirm hashing semantics with delegate present but owner signing.You now hash the delegate directly from input when present, regardless of who signed. That’s likely correct (account state should encode the delegate independent of signer), but if the previous code intentionally dropped the delegate when only the owner signed, this changes the hash.
- Please confirm intended behavior for:
- delegate present + owner signs (no delegate sig): delegate should still be hashed.
- delegate present + delegate signs: delegate hashed (unchanged).
- no delegate: None (unchanged).
If helpful, add a clarifying comment:
- let hashed_delegate = - delegate_account.map(|delegate| hash_cache.get_or_hash_pubkey(delegate.key())); + // Hash the configured delegate (if any), independent of which signer authorized. + let hashed_delegate = + delegate_account.map(|delegate| hash_cache.get_or_hash_pubkey(delegate.key()));
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
programs/compressed-token/program/src/shared/owner_validation.rs(3 hunks)programs/compressed-token/program/src/shared/token_input.rs(2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-10-11T21:59:25.222Z
Learnt from: CR
PR: Lightprotocol/light-protocol#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/compressed-token/program/src/shared/owner_validation.rs
🧬 Code graph analysis (1)
programs/compressed-token/program/src/shared/token_input.rs (1)
programs/compressed-token/program/src/shared/owner_validation.rs (1)
verify_owner_or_delegate_signer(11-51)
⏰ 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). (18)
- GitHub Check: stateless-js-v1
- GitHub Check: programs (light-system-program-address, ["cargo-test-sbf -p system-test -- test_with_address", "c...
- GitHub Check: programs (account-compression-and-registry, ["cargo-test-sbf -p account-compression-test", "cargo...
- GitHub Check: programs (system-cpi-test-v2-functional-account-infos, ["cargo-test-sbf -p system-cpi-v2-test -- ...
- 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-batched-tree, ["cargo-test-sbf -p compressed-token-test -- test_transf...
- GitHub Check: programs (compressed-token-and-e2e, ["cargo-test-sbf -p compressed-token-test --test v1", "cargo-...
- GitHub Check: programs (light-system-program-compression, ["cargo-test-sbf -p system-test -- test_with_compress...
- GitHub Check: lint
- GitHub Check: system-programs (anchor & pinocchio, ["cargo-test-sbf -p sdk-anchor-test", "cargo-test-sbf -p sdk...
- GitHub Check: cli-v1
- 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...
- GitHub Check: cli-v2
- GitHub Check: system-programs (token test, ["cargo-test-sbf -p sdk-token-test"])
- GitHub Check: Forester e2e test
- GitHub Check: stateless-js-v2
🔇 Additional comments (2)
programs/compressed-token/program/src/shared/token_input.rs (1)
87-87: Call site updated correctly.Authorization is enforced and no unused binding remains. Good.
programs/compressed-token/program/src/shared/owner_validation.rs (1)
38-38: Verification complete—all call sites are compatible.The function correctly returns
Result<(), ProgramError>with both success paths returningOk(())at lines 38 and 49. The only call site (token_input.rs:87) properly handles the Result type using the?operator. No problematic patterns detected (no variable assignments or Option method chains on the result).
Summary by CodeRabbit