Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CPI first pass impl #8

Closed
wants to merge 1 commit into from
Closed

Conversation

billythedummy
Copy link
Contributor

Tested out with some actual programs CPI-ing system program.

Feel free to critique design

&sol_ix as *const _ as *const _,
&sol_account_infos as *const _ as *const _,
sol_account_infos_len,
signers as *const _ as *const _,
Copy link
Collaborator

@febo febo Sep 5, 2024

Choose a reason for hiding this comment

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

We can't pass the signers rust references directly to the C code, since it expects the length of each individual seed unfortunately. I started adding signer "types" on this PR: https://github.com/febo/pinocchio/pull/11/files#diff-c14b0096da794786d77f37e2667c1f5cf800e7bf7875f8e99059e14857a03cf4R107-R127

Copy link
Collaborator

Choose a reason for hiding this comment

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

}
}

pub fn invoke_signed<'a, const MAX_ACCOUNTS_INCL_PROGRAM: usize>(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we need to add the borrow checks: https://github.com/anza-xyz/agave/blob/master/sdk/program/src/program.rs#L255-L269

We could have an unsafe *_unchecked variation without the checks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

btw do you know why the https://github.com/anza-xyz/agave/blob/master/sdk/program/src/program.rs#L255-L269 is doing this n^2 thing of looking for the corresponding AccountInfo for a given AccountMeta? Aren't both the AccountInfo and AccountMeta array supposed to be in the same order?

Copy link
Collaborator

Choose a reason for hiding this comment

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

They are not required to be in the same order.

Copy link
Collaborator

@febo febo left a comment

Choose a reason for hiding this comment

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

Looking good, thanks for preparing this!

I had started to add the types required for CPI in a separate PR (#11) so perhaps we can combine the effort.

@febo
Copy link
Collaborator

febo commented Sep 6, 2024

@billythedummy What do you think if we use the types from #11? We could merge #11 and then rebase this PR.

@billythedummy
Copy link
Contributor Author

@billythedummy What do you think if we use the types from #11? We could merge #11 and then rebase this PR.

Sure thing, please go ahead with any changes you're planning to make and feel free to merge or adapt all my open PRs; unfortunately I won't have a lot of time to dedicate to this until at least the end of breakpoint, apologies

@febo
Copy link
Collaborator

febo commented Sep 13, 2024

Closing this as the changes suggested on this PR were added to #11 – thank you for your contribution @billythedummy.

@febo febo closed this Sep 13, 2024
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