coral-xyz / anchor

⚓ Solana Sealevel Framework
https://anchor-lang.com
Apache License 2.0
3.36k stars 1.25k forks source link

Replace solana_program::program::invoke with solana_invoke::invoke #2958

Open deanmlittle opened 1 month ago

deanmlittle commented 1 month ago

Creating this PR to get the conversation started. Thanks @cavemanloverboy. Running some A/B tests locally now against my own escrow program that does some basic CPI calls. Will report back shortly. Check out solana-invoke to see how it works. 🙏

vercel[bot] commented 1 month ago

@deanmlittle is attempting to deploy a commit to the coral-xyz Team on Vercel.

A member of the Team first needs to authorize it.

deanmlittle commented 1 month ago

Yes, this should definitely be merged into solana-program. At the same time, if we can significantly reduce CU usage today without waiting for an upstream merge that may or not may not even happen, would that not be better than leaving it as is?

cavemanloverboy commented 1 month ago

Historically, I've had trouble getting PRs into agave. Either ignored or takes far too long. Since the instruction stabilizer has a few tricky unsafe bits, I suspect it will receive pushback.

cavemanloverboy commented 1 month ago

Thanks for creating the PR, it's an interesting one.

The README mentions:

The current CPI functions solana_program::program::invoke* perform unnecessary copies and allocations. This crate removes these inefficiencies in a manner that is 100% backwards compatible.

If this really is 100% backwards compatible, and is objectively better than solana_program's implementation, why not PR this to change it from solana-program side? Both Anchor and Native programs would get the benefits this way.

this is why lol

https://github.com/anza-xyz/agave/pull/1426