Skip to content

Account borrow state check#147

Merged
febo merged 5 commits into
mainfrom
febo/cpi-tweaks
May 1, 2025
Merged

Account borrow state check#147
febo merged 5 commits into
mainfrom
febo/cpi-tweaks

Conversation

@febo
Copy link
Copy Markdown
Collaborator

@febo febo commented Apr 30, 2025

Problem

The account borrow check done on CPIs is slightly more expensive than it needs to be, since it also checks whether another borrow can be made or not.

Solution

Create a BorrowState enum to represent different borrow masks. This allows to perform checks on the account borrow state. This will enable CPI helpers that already set the accounts in the correct order to use *_unchecked variants, but still perform borrow checks.

It also makes 2 other improvements related to CPIs:

  • inlines the invoke_signed_unchecked
  • uses a MaybeUnit for the pubkey in the get_return_data

@febo febo force-pushed the febo/cpi-tweaks branch from 7597cbe to 29da007 Compare April 30, 2025 11:31
@febo febo requested a review from joncinque April 30, 2025 11:36
Copy link
Copy Markdown
Collaborator

@joncinque joncinque left a comment

Choose a reason for hiding this comment

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

This looks really great! Just a couple of nits

Comment thread sdk/pinocchio/src/account_info.rs Outdated
Comment thread sdk/pinocchio/src/account_info.rs Outdated
Comment thread sdk/pinocchio/src/account_info.rs Outdated
Base automatically changed from febo/nostd-fallback to main April 30, 2025 23:31
@febo febo force-pushed the febo/cpi-tweaks branch from f9c9774 to 1fe1e8a Compare May 1, 2025 00:24
@febo febo requested a review from joncinque May 1, 2025 01:19
@febo febo merged commit 59aa6cb into main May 1, 2025
9 checks passed
@febo febo deleted the febo/cpi-tweaks branch May 1, 2025 11:30
publicqi added a commit to publicqi/pinocchio that referenced this pull request May 5, 2025
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