-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Cross-program balanced instruction handling is too restrictive #9711
Comments
@jackcmay - do you want to keep this in 1.2 or punt to 1.3? |
@mvines I think given the other priorities punting to 1.3 is more realistic |
Looks like this is breaking Wormhole guardian set upgrades, which - if the subsidizer pool is full - do:
Reproduction instructions:
|
@leoluk One workaround is to do all in-program transfers at the end of a program's execution, is that possible here? |
This works around solana-labs/solana#9711 which causes issues when the guardian set creation is subsidized and another CPI call is done subsequently
* don't subsidize guardian set creation This works around solana-labs/solana#9711 which causes issues when the guardian set creation is subsidized and another CPI call is done subsequently
Does anyone ever intend to fix this? I have not tried it yet but I think this means programs cannot do the following basic procedure:
|
+1 trying to do the exact same use case that @billythedummy speaks about. transfer + sync native It's not possible right now, so what is a workaround? |
Any updates on this one?
|
Now, I am also trying to do this. |
@toptalhook The only thing you can do is wrap the SOL on a normal(non-program-owned) account and transfer wSOL to the program-owned account. |
This is still not possible in 2024. Please, someone take a look. |
To understand how to work around this runtime constraint, it's important to understand that whenever an instruction is processed in the SVM, the latest lamport balance of each instruction account is recorded and tracked. Later when a CPI is made with just a subset of those accounts, it performs balanced lamport check by adding the latest lamports for the subset of accounts passed to the CPI instruction to the sum of the last known lamport balances of the accounts that were passed to the parent instruction but not to the child CPI instruction. This sum must be the same as the sum of all last known account lamport balances when the parent instruction began processing. So let's say you had an instruction TL;DR: append all accounts with lamport changes to the end of your CPI instruction accounts list. |
Problem
The
MessageProcessor
's balanced instruction check ensures the Lamport sum of all accounts in the instruction remains the same before and after the instruction. Cross-program invocations only include the accounts required by the invoked instruction and thus leaves out any transfers the invoking program may have made to other accounts before the call to invoke.For example:
For programs
A
andB
and accountsX
,Y
,Z
It requires developers to be aware of when they transfer tokens relative to any invocations they are making.
Proposed Solution
Include all accounts in the balance calculations
The text was updated successfully, but these errors were encountered: