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

Removes cap-accounts-data-len bits when constructing a new Bank #34688

Merged

Conversation

brooksprumo
Copy link
Contributor

@brooksprumo brooksprumo commented Jan 8, 2024

Problem

Setting a limit for the total accounts data size12 breaks consensus and cannot work3. The same issue exists for setting a limit per block4. Yet, we still have featurization code for both. This is an issue for a few reasons:

  1. Readers of the code have to already know these features will not be enabled, and thus ignore them.
  2. Tests that enable all features may fail if they are designed to stress the accounts database. This happens with the pop-net cluster, and we instead manually rip out the feature code.
  3. When developing new code that interacts with the accounts data size, the developer is forced to deal with this feature's code, which can be non-obvious.

Some of the lowest hanging fruit to make developer-experience better is to rip out the code during Bank construction that activates the tracking/limiting.

Summary of Changes

Remove the code during Bank construction that enables/configures the accounts data size limits:

  1. The CostTracker
  2. The initial accounts data size

Footnotes

  1. https://github.com/solana-labs/solana/issues/24135

  2. https://github.com/solana-labs/solana/issues/21604

  3. https://github.com/solana-labs/solana/issues/27029

  4. https://github.com/solana-labs/solana/issues/25517

@brooksprumo brooksprumo self-assigned this Jan 8, 2024
Comment on lines -1320 to -1328
cost_tracker: RwLock::new(CostTracker::new_with_account_data_size_limit(
feature_set
.is_active(&feature_set::cap_accounts_data_len::id())
.then(|| {
parent
.accounts_data_size_limit()
.saturating_sub(accounts_data_size_initial)
}),
)),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is within new_from_parent(). By not setting CostTracker::account_data_size_limit, we won't enforce a total accounts data size limit during transaction processing.

Comment on lines -6627 to -6635
if self
.feature_set
.is_active(&feature_set::cap_accounts_data_len::id())
{
self.cost_tracker = RwLock::new(CostTracker::new_with_account_data_size_limit(Some(
self.accounts_data_size_limit()
.saturating_sub(self.accounts_data_size_initial),
)));
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same thing as above, just that this covers the new_from_paths() and new_from_fields() constructors. IOW, starting up from genesis or a snapshot.

Comment on lines -7863 to -7866
if new_feature_activations.contains(&feature_set::cap_accounts_data_len::id()) {
const ACCOUNTS_DATA_LEN: u64 = 50_000_000_000;
self.accounts_data_size_initial = ACCOUNTS_DATA_LEN;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was a hack to set a deterministic value for the initial total accounts data size. It's also quite wrong, value-wise, now.

@brooksprumo brooksprumo marked this pull request as ready for review January 8, 2024 15:20
Copy link

codecov bot commented Jan 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (30fa449) 81.8% compared to head (4a74e53) 81.8%.

Additional details and impacted files
@@            Coverage Diff            @@
##           master   #34688     +/-   ##
=========================================
- Coverage    81.8%    81.8%   -0.1%     
=========================================
  Files         824      824             
  Lines      222687   222672     -15     
=========================================
- Hits       182245   182215     -30     
- Misses      40442    40457     +15     

@tao-stones
Copy link
Contributor

Changes to remove cap_accounts_data_len from bank.rs look good. This seems to make bank tests test_accounts_data_size_with_good_transaction and test_accounts_data_size_with_bad_transaction unnecessary? if so, these two tests can also be removed.

CostTracker.account_data_size_limit and logic based on it can also be removed, perhaps in separate PR?

@brooksprumo
Copy link
Contributor Author

brooksprumo commented Jan 8, 2024

This seems to make bank tests test_accounts_data_size_with_good_transaction and test_accounts_data_size_with_bad_transaction unnecessary? if so, these two tests can also be removed.

We still want to track the accounts data size in the bank, which transactions update. So these two tests are both still useful.

Edit: I'll investigate why these tests use the cap_accounts_data_len feature though.

CostTracker.account_data_size_limit and logic based on it can also be removed, perhaps in separate PR?

Yep! I have PRs already queued up to remove these bits.

@brooksprumo
Copy link
Contributor Author

I'll investigate why these tests use the cap_accounts_data_len feature though.

I've created #34701 to cleanup the tests. Both can proceed concurrently, as they do not impact each other. So this PR is ready for another review, @taozhu-chicago. Thanks!

Copy link
Contributor

@tao-stones tao-stones 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
Copy link
Contributor

I'll investigate why these tests use the cap_accounts_data_len feature though.

I've created #34701 to cleanup the tests. Both can proceed concurrently, as they do not impact each other. So this PR is ready for another review, @taozhu-chicago. Thanks!

Sounds good! Happy to review #34701 too

@brooksprumo brooksprumo merged commit 40e4103 into solana-labs:master Jan 8, 2024
35 checks passed
@brooksprumo brooksprumo deleted the cap-accounts-data-len/remove/new branch January 9, 2024 00:15
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