Skip to content

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

Open
wants to merge 27 commits into
base: main
Choose a base branch
from

Conversation

rustopian
Copy link

@rustopian rustopian commented Jun 28, 2025

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".

@rustopian rustopian changed the title SIMD create-account-prefunded SIMD-0312 create-account-prefunded Jun 28, 2025
@rustopian rustopian marked this pull request as draft June 28, 2025 13:46
@rustopian rustopian changed the title SIMD-0312 create-account-prefunded SIMD-0312: CreateAccountPrefunded Jun 28, 2025
Copy link
Contributor

@joncinque joncinque left a 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

Comment on lines 55 to 59
## 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`.
Copy link
Contributor

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.

Comment on lines 52 to 53
* 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.
Copy link
Contributor

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?

Copy link
Author

@rustopian rustopian Jul 10, 2025

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?

Copy link
Contributor

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

Copy link
Author

@rustopian rustopian Jul 10, 2025

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.

@rustopian rustopian changed the title SIMD-0312: CreateAccountPrefunded SIMD-0312: CreatePrefundedAccount Jul 10, 2025
@rustopian rustopian marked this pull request as ready for review July 10, 2025 12:14
Copy link
Contributor

@joncinque joncinque left a 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
Copy link
Contributor

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 25fddea

@rustopian rustopian requested a review from joncinque July 25, 2025 11:42
Copy link
Contributor

@joncinque joncinque left a 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!

@rustopian
Copy link
Author

rustopian commented Jul 30, 2025

@t-nelson or @jstarry, requesting a review at your convenience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants