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

Propose to remove new account creation data size check from cost model #30204

Closed
tao-stones opened this issue Feb 8, 2023 · 7 comments
Closed
Labels
stale [bot only] Added to stale content; results in auto-close after a week.

Comments

@tao-stones
Copy link
Contributor

tao-stones commented Feb 8, 2023

Problem

As part of effort to define detailed costs for accounts (such as costs to load read/write/executable/lookup accounts, and costs of loaded account data size, etc), I would like to clean up this block of code that limits how many new account data size each block can allocate, utilizing cost_model.

For context, it was implemented as a quick way to limit data size accounts can take, adding preventive check at leader side was the quickest way. However, due to the fact that cost_model functions before transactions being processed, the implementation was limited to check only instructions that create accounts.

Since then more comprehensive approaches were consisted and implemented: (thanks to @brooksprumo for documenting)

Capping allocations per transaction

Capping total loaded account data size

IMO, with these two changes, the block of code in question can/should be removed. POC here. It would not only clean up the code, gain some perf back, also make it easier to define cost for data size accounts loads.

Some other resources/contexts:

Capping total accounts data size

Capping allocations per block

Proposed Solution

@mvines
Copy link
Contributor

mvines commented Feb 9, 2023

seems reasonable. does #30205 need a feature gate as well, or no since the behavior change only affects the current slot leader?

@tao-stones
Copy link
Contributor Author

No need feature gate if "land this before #30035", otherwise need to be gated. Another motivation for do it now 😄

@tao-stones
Copy link
Contributor Author

Also checked the metrics, mainnet-beta seems never hit this check anyway:

SELECT max("would_exceed_account_data_block_limit") AS "max_would_exceed_account_data_block_limit" FROM "mainnet-beta"."autogen"."banking_stage-leader_slot_transaction_errors" WHERE time > :dashboardTime: AND time < :upperDashboardTime: GROUP BY time(:interval:) FILL(null)

@brooksprumo
Copy link
Contributor

These checks in the cost model are the only way to add limits on new allocations within a block. We'll be able to limit new allocations per transaction with #27375, but we won't be able to limit allocations per block (#25517) elsewhere.

As noted, the current checks are not comprehensive in what they can—and do—check, so it may be appropriate to remove them. I'm not sure I am willing to be that person though 😸

@tao-stones
Copy link
Contributor Author

tao-stones commented Feb 9, 2023

Good point to distinguish per-transaction and per-block. I wonder if limiting allocation per block has actual use. Transactions from multiple blocks are replayed simultaneously anyway. Before being able to limit-per-transaction, set cap per block helps a bit. Since we can set limit per transaction now (limits on both new allocation per tx, and total data loaded per tx), hence time to reevaluate the need of limit-allocations-per-block.

@t-nelson
Copy link
Contributor

does #27385 account for both system program allocations and the realloc syscall?

@brooksprumo
Copy link
Contributor

does #27385 account for both system program allocations and the realloc syscall?

Yep!

if self
.transaction_context
.is_cap_accounts_data_allocations_per_transaction_enabled
{
// The resize can not exceed the per-transaction maximum
let length_delta = (new_length as i64).saturating_sub(old_length as i64);
if self
.transaction_context
.accounts_resize_delta()?
.saturating_add(length_delta)
> MAX_PERMITTED_ACCOUNTS_DATA_ALLOCATIONS_PER_TRANSACTION
{
return Err(InstructionError::MaxAccountsDataAllocationsExceeded);
}
}

@github-actions github-actions bot added the stale [bot only] Added to stale content; results in auto-close after a week. label Feb 15, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 23, 2024
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

Successfully merging a pull request may close this issue.

4 participants