-
Notifications
You must be signed in to change notification settings - Fork 177
SIMD-0312: CreatePrefundedAccount #312
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
base: main
Are you sure you want to change the base?
SIMD-0312: CreatePrefundedAccount #312
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me overall! Mostly some small points
## Detailed Design | ||
|
||
`create_account_prefunded()` takes the same arguments as `create_account()` | ||
and performs the same operations; however, it does not fail if the new | ||
account's `lamports > 0`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section could use a little more detailed information for other teams implementing validators, like Firedancer, including the following:
- exact instruction data format, ie the discriminant and expected value
- exact accounts in order, and their role (readonly, writable, signer, writable-signer)
- special cases. For example, if the transfer amount is 0, is a payer account even required? If not, then we don't perform any checks on the payer account.
* Prefunded: an account which receives lamports to pay for its rent in whole | ||
or in part before its space is `allocate`d and its owner is `assign`ed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: the term would be "prefunded account" then. And isn't a prefunded account one that may receive lamports?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to Prefunded Account in 145e947. However, no, if it hasn't received lamports, it is no different, and is treated no differently, than a non-prefunded account. Or how do you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean that in the instruction, the prefunded account may receive lamports. The possibilities are:
- the account has 0 lamports, it's not prefunded, so it does receive lamports
- the account is partially funded, but not enough for rent-exemption, so it's prefunded and it receives lamports
- the account has enough for rent-exemption, so it's prefunded but it receives no lamports
So what I mean: the optionality of receiving lamports is important
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see what you mean. I'm defining it as an account that has received lamports prior to the create transaction/instruction, but the original definition sounds like it could refer the lamports transfer
which occurs in the CreatePrefundedAccount
call itself.
By "which receives lamports," I meant to refer to the funding in advance of creation (perhaps months before, for example).
I've clarified to:
* Prefunded Account: an account which has received lamports to pay for its rent
in whole or in part in any prior instruction or prior transaction, before the
instruction in which its space is `allocate`d and its owner is `assign`ed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Just the last question that we've been kicking around a bit for the payer
|
||
| Index | Role | Description | | ||
|---|---|---| | ||
| 0 | `[WRITE, SIGNER]` | **Funding account**: The account that will pay |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about making this account optional? This would make it different from CreateAccount
, but that should be ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated in 25fddea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me!
CreateAccountPrefunded
Emerging from discussions around work on a newer ATA program.
Someday, multi-instruction wrappers such as
CreateAccount
will not be as necessary for efficiency as they are today.Until then,
CreateAccountPrefunded
offers quick and sizable compute savings for the common flow "fund account rent first, then create the account later".