fix: correct CPI bugs in group_pointer and cpi_guard extensions#4334
fix: correct CPI bugs in group_pointer and cpi_guard extensions#4334alexchenai wants to merge 3 commits intosolana-foundation:masterfrom
Conversation
…ard) - group_pointer_update: include authority AccountInfo in invoke_signed accounts slice, matching the pattern in group_member_pointer_update. Without this, the CPI always fails since the runtime cannot find the authority account. Fixes solana-foundation#4323. - cpi_guard_enable/disable: pass ctx.accounts.owner.key (token account authority) instead of ctx.accounts.account.owner (runtime account owner / program ID) when building the CPI guard instruction. The SPL Token-2022 processor validates this against the stored token authority, so using .owner always results in OwnerMismatch. Matches the pattern used in memo_transfer.rs. Fixes solana-foundation#4321.
|
Someone is attempting to deploy a commit to the Solana Foundation Team on Vercel. A member of the Team first needs to authorize it. |
|
Sounds like these instructions were completely broken? 👀 Can we add a test to prevent this recurring |
|
Yes, the instructions were broken — both Absolutely agree on adding tests. I will add integration tests that:
Will push the test additions shortly. |
|
Tests added in the latest two commits: cpi_guard.rs (commit 2deb0fb):
group_pointer.rs (commit 8f049ee):
Both test modules use |
|
This test seems rather tautological, and does not test any Anchor functionality or the fix made here. Can we use a proper integration test with a test validator? |
|
Agreed — the unit tests I added check the instruction builder in isolation, which is tautological since we call the same library we are testing. I will add a proper integration test in
This directly tests the bug fix rather than the instruction builder. Will push the integration test shortly. |
Fixes two CPI bugs in
spl/src/token_2022_extensions/:1.
group_pointer_update(fixes #4323)The
authorityAccountInfowas missing from the accounts slice passed toinvoke_signed. The instruction is built with the authority pubkey but the CPI omits it, so the call always fails. The analogousgroup_member_pointer_updateingroup_member_pointer.rscorrectly includes it.2.
cpi_guard_enable/cpi_guard_disable(fixes #4321)Both functions pass
ctx.accounts.account.owner(the Solana runtime account owner, i.e. the Token-2022 program ID) instead ofctx.accounts.owner.key(the token account authority) when constructing the CPI guard instruction. The SPL Token-2022 processor validates this parameter against the stored token authority, so the CPI always fails withOwnerMismatch. The analogous functions inmemo_transfer.rscorrectly usectx.accounts.owner.key.Changes
spl/src/token_2022_extensions/group_pointer.rs: Addctx.accounts.authoritytoinvoke_signedaccounts slicespl/src/token_2022_extensions/cpi_guard.rs: Replacectx.accounts.account.ownerwithctx.accounts.owner.keyin both enable and disableCloses #4323
Closes #4321