Skip to content
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

fix account resize test by requesting max tx data size #28826

Merged
merged 3 commits into from
Nov 16, 2022

Conversation

tao-stones
Copy link
Contributor

Problem

test_accounts_data_size_and_resize_transactions(): generate random account data size without compute_budget instruction to set tx's max data size. When the randomly generated account size exceeds default 10M limit, transaction will fail due to MaxLoadedAccountsDataSizeExceeded

Summary of Changes

  • add compute_budget instruction to set correct tx max data size limit

Fixes #

@tao-stones
Copy link
Contributor Author

This fixes issues described in #28814

Copy link
Contributor

@brooksprumo brooksprumo left a comment

Choose a reason for hiding this comment

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

Do you prefer explicitly setting the accounts data size load limit vs the current solution of just using smaller account sizes?

@@ -19479,6 +19479,7 @@ pub(crate) mod tests {
new_balance: u64,
mock_program_id: Pubkey,
recent_blockhash: Hash,
tx_data_size_limit: u32,
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this fn is only used in tests, and those tests are not meant to exercise the ComputeBudget's load-account-data-size cap, I think it'd be nicer to not take this parameter here, and instead just call ComputeBudgetInstruction::set_accounts_data_size_limit() with u32::MAX.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Initially added the exact tx data size limit as a way to demonstrate the usage of set_accounts_data_size_limit(). But agree this may pollute this test. Replaced it with u32::MAX

@@ -19780,6 +19790,7 @@ pub(crate) mod tests {
/// Ensure that accounts data size is updated correctly on resize transactions
#[test]
fn test_accounts_data_size_and_resize_transactions() {
solana_logger::setup();
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Can this be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

@tao-stones
Copy link
Contributor Author

perhaps the easiest fix is to redefine

const DEFAULT_LOADED_ACCOUNTS_DATA_LIMIT: u32 = 10_000_000 10 * 1024 * 1024

@brooksprumo
Copy link
Contributor

perhaps the easiest fix is to redefine

const DEFAULT_LOADED_ACCOUNTS_DATA_LIMIT: u32 = 10_000_000 10 * 1024 * 1024

Ahhh, that could the be issue!

Also, does loading the system program count against the account data load limit (even though it lives in the runtime vs on-chain)?

@tao-stones
Copy link
Contributor Author

does loading the system program count against the account data load limit (even though it lives in the runtime vs on-chain)?

Yea, transaction's account data size is the sum of all accounts being loaded into memory.

@tao-stones
Copy link
Contributor Author

Do you prefer explicitly setting the accounts data size load limit vs the current solution of just using smaller account sizes?

Calling set_accounts_data_size_limit(u32::MAX) feels more solid test setup to me.

@brooksprumo
Copy link
Contributor

Yea, transaction's account data size is the sum of all accounts being loaded into memory.

@taozhu-chicago So does that mean a transaction that creates a single max-sized account would still fail? (Assuming it does not call ComputeBudgetInstruction::set_accounts_data_size_limit().)

@tao-stones
Copy link
Contributor Author

tao-stones commented Nov 16, 2022

So does that mean a transaction that creates a single max-sized account would still fail? (Assuming it does not call ComputeBudgetInstruction::set_accounts_data_size_limit().)

Yea, it needs to call to set limit, otherwise it'd fail -- is this a problem? Is it necessary to exclude builtin programs in count data size towards limit? Think it again, and chat with @Lichtso, builtin should be handled same as any programs wrt data size limit.

@brooksprumo
Copy link
Contributor

Yea, it needs to call to set limit, otherwise it'd fail -- is this a problem? Is it necessary to exclude builtin programs in count data size towards limit?

I guess I was under the impression that the 10 MB default load-limit was calculated so that a single max-sized account could be created without needing to call ComputeBudgetInstruction::set_accounts_data_size_limit().

But that was my assumption. So, if that's not the intent by the default 10 MB limit, that is also OK; and then the default limit does not need to be changed here.

It may be useful to know what the load-limit must be set to in order to create a max-sized account.

@brooksprumo brooksprumo self-requested a review November 16, 2022 19:45
Copy link
Contributor

@brooksprumo brooksprumo left a comment

Choose a reason for hiding this comment

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

I think the changes look good. But, if the the system program counts against the load budget, won't the test still fail if the account data size ends up being the 10 MiB max?

Edit: Nevermind, forgot that the load limit was bumped up to u32::MAX

@tao-stones
Copy link
Contributor Author

won't the test still fail if the account data size ends up being the 10 MiB max?

Yeah, in early commit (before change to u32::MAX), compute_budget instruction set limit to (10Mib + mock_realloc_account_size + compute_budget_account_size) = 10MiB + 20B + 22B. That's awkward but did make test valid. But these details shouldn't bother the test itself, so u32::MAX is better :)

BTW, the need to loading builtin is discussed separately. Hopefully soon to be able to not loading builtin programs, then the default limit of 10MiB can perfectly load a max sized account.

Copy link
Contributor

@brooksprumo brooksprumo left a comment

Choose a reason for hiding this comment

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

Lgtm

@tao-stones tao-stones merged commit ae48ac9 into solana-labs:master Nov 16, 2022
@tao-stones tao-stones deleted the fix_bank_test branch November 16, 2022 23:52
gnapoli23 pushed a commit to gnapoli23/solana that referenced this pull request Dec 16, 2022
…8826)

* fix account resize test by requesting max tx data size
* define data size limit in incremental of 1024
tao-stones added a commit that referenced this pull request Dec 22, 2022
nickfrosty pushed a commit to nickfrosty/solana that referenced this pull request Jan 4, 2023
…8826)

* fix account resize test by requesting max tx data size
* define data size limit in incremental of 1024
tao-stones added a commit that referenced this pull request Jan 13, 2023
tao-stones added a commit that referenced this pull request Jan 17, 2023
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