Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Provide transaction fee payer and system program via sysvars #18588

Closed
armaniferrante opened this issue Jul 11, 2021 · 1 comment
Closed

Provide transaction fee payer and system program via sysvars #18588

armaniferrante opened this issue Jul 11, 2021 · 1 comment
Labels
stale [bot only] Added to stale content; results in auto-close after a week.

Comments

@armaniferrante
Copy link
Contributor

armaniferrante commented Jul 11, 2021

When creating accounts inside an instruction, one needs to provide two additional accounts, which are often not otherwise used--the system program and payer--for the CPI to the system program

It would be convenient to be able to reference these AccountInfos via sysvars, so that clients don't need to provide them in the transaction, and so that programs can abstract away this detail.

For example, in Anchor, we have to define a set of accounts creating + initializing an account as follows

#[derive(Accounts)]
pub struct MyInstruction<'info> {
    #[account(init, payer = my_payer)]
    my_account: ProgramAccount<'info, Data>,
    my_payer: AccountInfo<'info>,
    system_program: AccountInfo<'info>,
    rent: Sysvar<'info, Rent>,
}

But it would be nice to only define the single relevant account.

#[derive(Accounts)]
pub struct MyInstruction<'info> {
    #[account(init)]
    my_account: ProgramAccount<'info, Data>,
}
@ryoqun
Copy link
Contributor

ryoqun commented Jul 14, 2021

yeah, I know correctly spelling out each and every accounts for cpi is cumbersome and bad for defi composability...

that's the reason I'm trying to propose #17796 .

It would be convenient to be able to reference these AccountInfos via sysvars (EDIT: syscalls)

in fact, sysvars should be available via syscalls by now.

payer

This is a bit hard part. Enabling arbitrary programs to load fee payer AccountInfo with is_signer=true opens wide variety of over-authorization (for example, the signer bit might also be used for withdraw_authority in stake problem, for example)... we have to wholly trust all programs invoked cpi (this is somewhat lenient threat model; already we're kind of trust them)... I have to think if there could be a nice way to fix the general sol management problem..

maybe implement system_program::{create,assign}UsingFeePayer and warn if too large SOL is spent?

i mean, i'm slightly inclined to the state where users don't need to fully trust every program they play with (ala. web2 security model). That's the reason I'm thinking about AssertSplBalances instruction, which is possibly appended to txes by the wallet.

@github-actions github-actions bot added the stale [bot only] Added to stale content; results in auto-close after a week. label Dec 26, 2022
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
stale [bot only] Added to stale content; results in auto-close after a week.
Projects
None yet
Development

No branches or pull requests

2 participants