anza-xyz / anza-xyz/solana-sdk
`solana_loader_v3_interface::instruction::close_any()` accepts invalid parameters
- Dominant language
- Rust
- Stars
- 256
- Forks
- 250
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 39
Description
Currently, calling [`close_any()`](https://github.com/anza-xyz/solana-sdk/blob/822be4736ed01c4170740c804da3b22c39a2bfe7/loader-v3-interface/src/instruction.rs#L521-L543) with the following parameter shape
```rs
close_any(close_addr,
recipient_addr,
None, // authority_address
Some(program_address),
false)
```
returns an (invalid) `Instruction`, where the provided `program_address` is incorrectly placed in the `AccountMeta` vector at index 2 (where `authority_address` is supposed to live). Hence, this instruction will fail at runtime.
If we are OK with a breaking change, we should make the `authority_address.is_none() && program_address.is_some()` unrepresentable, such as something along the lines of
```rs
enum CloseTarget<'a> {
Uninitialized,
Buffer { authority: &'a Pubkey },
Program { authority: &'a Pubkey, program: &'a Pubkey
}
pub fn close_any(
close_address: &Pubkey,
recipient_address: &Pubkey,
target: CloseTarget,
tombstone: bool,
) -> Instruction {
...
}
```
Otherwise, we could at least add a debug assertion to reject `authority_address.is_none() && program_address.is_some()`.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.