Commit Graph

226 Commits

Author SHA1 Message Date
Brooks 725ab37bf4
clippy: Replaces .get(0) with .first() (#34048) 2023-11-13 17:22:17 -05:00
Jeff Washington (jwash) a25eae41fc
stop page aligning shrunk append vecs (#34016)
* stop page aligning shrunk append vecs

* fix build

* fix test by removing aligned alive page bytes asserts

* rm dup assert

---------

Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-11-13 14:22:26 -06:00
Yueh-Hsuan Chiang 2b9054a60e
[TieredStorage] HotStorageReader::get_account_offset (#34031)
#### Problem
HotStorageReader currently not yet has an API to obtain account_offset

#### Summary of Changes
This PR adds HotStorageReader::get_account_offset() which takes
IndexOffset and returns AccountOffset.

#### Test Plan
A new unit-test is included in this PR.
2023-11-13 12:07:09 -08:00
Yueh-Hsuan Chiang 3db7eaf1fc
[TieredStorage] Improve param naming of IndexBlockFormat (#34033)
#### Problem
In IndexBlockFormat, both `IndexOffset` and `AccountOffset` parameters
are named `offset` in some functions which could be confusing.

#### Summary of Changes
Renamed `offset` to `index_offset` and `account_offset` to improve
readability.
2023-11-13 12:05:25 -08:00
Brooks 3c71f859e1
Uses fold+reduce for handling duplicate pubkeys during index generation (#34011) 2023-11-10 14:32:24 -05:00
Brooks 69ab8a8234
Uses IntSet for uncleaned slots from visit_duplicate_pubkeys_during_startup() (#34009) 2023-11-10 11:29:13 -05:00
Pankaj Garg 59eb55990c
Move filter_executable_program_accounts to bank.rs (#34004) 2023-11-09 14:40:04 -08:00
Brooks 9f25f67e60
Simplifies adding uncleaned pubkeys during index generation (#34007) 2023-11-09 16:06:15 -05:00
Brooks a96be5d2f0
Uses IntSet for uncleaned roots during index generation (#34008) 2023-11-09 15:04:19 -05:00
Yueh-Hsuan Chiang 874fae507f
[TieredStorage] Make HotStorageReader use AccountOffset type (#33964)
#### Problem
#33927 introduced a new type AccountOffset, but HotStorageReader
still uses `usize` to access accounts.

#### Summary of Changes
This PR makes HotStorageReader use the new AccountOffset type.
2023-11-08 21:58:44 -08:00
Brooks bba6ea2d69
Returns IntMap from select_candidates_by_total_usage() (#33976) 2023-11-08 16:15:51 -05:00
Brooks 7cb83bc491
Adds `S` to HashMap/HashSet impls of Contains (#33973) 2023-11-08 15:08:33 -05:00
Brooks 6f213c38aa
Removes Default from RollingBitField (#33969) 2023-11-07 15:58:52 -05:00
Yueh-Hsuan Chiang b013c03afa
[TieredStorage] Add IndexOffset type (#33929)
#### Problem
TieredStorage conceptually has different offsets. However, the current code directly
uses the same primitive type for accessing offsets, which is error-prone as one could
easily use one offset to access data that should be accessed with a different offset
type.

#### Summary of Changes
This PR adds IndexOffset type -- a struct for obtaining the ith entry inside the
index-block to obtain account's offset and address.
2023-11-07 10:26:21 -08:00
Jeff Washington (jwash) b8115b4303
chunk all ancient append vecs (#33909)
* chunk all ancient append vecs

* fix a test comments

* remove unneeded dead_code attr

* do full chunking when pack is used to create ancient storage

* refacotr and fix tests

* clippy

* add cache hash file stats

* comments

* fix test

* Update accounts-db/src/accounts_db.rs

Co-authored-by: Brooks <brooks@prumo.org>

* Update accounts-db/src/accounts_db.rs

Co-authored-by: Brooks <brooks@prumo.org>

* test_case

* remove commented out code

* remove hash cache data stats

* typo

---------

Co-authored-by: HaoranYi <haoran.yi@solana.com>
Co-authored-by: HaoranYi <haoran.yi@gmail.com>
Co-authored-by: Brooks <brooks@prumo.org>
2023-11-07 09:10:59 -06:00
Lijun Wang 8c69a0ec38
Remove RwLock on AccountsUpdateNotifier (#33960) 2023-11-06 14:03:25 -08:00
Yueh-Hsuan Chiang da130b87d3
[TieredStorage] Add AccountOffset type (#33927)
#### Problem
TieredStorage conceptually has different offsets.  However, the current code directly
uses the same primitive type for accessing offsets, which is error-prone as one could
easily use one offset to access data that should be accessed with a different offset
type.

#### Summary of Changes
This PR introduces the AccountOffset type, which allows static-check to on different
type of TieredStorage offsets.
2023-11-06 12:21:08 -08:00
Brooks 70d97d3261
Adds `iter_ones()` to RollingBitField (#33956) 2023-11-06 14:06:43 -05:00
Yueh-Hsuan Chiang 6624a09d38
[TieredStorage] Rename account-index to index-block (#33928)
#### Problem
The current tiered-storage code uses "account-index" to call index-block.
This could lead to confusion especially as we start giving each offset/position/index a specific type.

#### Summary of Changes
This PR renames all structs/variables that use account-index to refer to index-block.
2023-11-06 10:32:19 -08:00
Brooks cdc284189a
Refactors RollingBitField::min() (#33911) 2023-10-28 12:47:29 -04:00
Brooks 1814b2bc81
Adds logs for starting/stopping of the background account hasher (#33903) 2023-10-27 13:03:33 -04:00
Jeff Washington (jwash) a18debc34a
allow test feature to skip rewrites (#33851)
* allow test feature to skip rewrites

* hook up cli arg for test skip rewrites, update tests

* fix sanity checker

* add account hash to abi to fix a test

* reviews

* use hashmap to collect skip_rewrites. exclude skip_rewrites from dirty
pubkey set

* accumulate skipped_rewrite in reduce

* mutex

* fmt

* skip hash verify for this test flag

* add skipped rewrites num stat

* skip bank hash verify not account hash verify

* reviews

---------

Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-10-27 09:14:05 -05:00
Tao Zhu 510b6b949f
Split compute budget instructions process from struct (#33852)
* Split compute budget instruction processing from ComputeBudget struct itself, so CB instructions can be processed elsewhere without involving ComputeBudget

* updated tests

* avoid built ComputeBudget from dated ComputeBudgetLimits in this refactoring PR

* Clean-up program-runtime/src/compute_budget_processor.rs

* Add test for a corner case that deprecated instruction is used to request units greater than max limit;
* Update code to handle the corner case.
2023-10-26 22:12:56 -05:00
Brooks bd1080b26f
Adds AtomicAge to bucket map holder (#33841) 2023-10-25 10:47:21 -04:00
Kevin Heavey af7fd32f4c
chore: fix some typos (#33833)
* fix spelling of "retrieved"
* fix spelling of "should"
* fix spelling of "comparisons"
2023-10-25 16:21:53 +02:00
Brooks 612e8e8457
Removes Default and pub from CumulativeOffset (#33840) 2023-10-24 19:22:34 +00:00
Brooks abf51864b4
Removes `#[allow(dead_code)]` in StorableAccounts impl (#33821) 2023-10-24 18:31:27 +00:00
HaoranYi 9064b8b2a2
Optimize account hash CumulativeOffset index from vec to 2-element array (#33839)
* optimize account hash merkle tree index from vec to 2-element array

* typo

---------

Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-10-24 18:26:16 +00:00
Brooks 2f024f0cc1
Uses AccountHash in CalculateHashIntermediate (#33822) 2023-10-24 08:39:32 -04:00
Jeff Washington (jwash) b0b4e1f0c0
remove IncludeSlotInHash after feature activation on mnb (#33816)
* remove IncludeSlotInHash after feature activation on mnb

* fix compile errors

* compile errors

* fix tests

* fix test results
2023-10-23 15:12:02 -07:00
Jeff Washington (jwash) 54b796f5a1
ancient pack: add low water mark (#33785) 2023-10-23 10:56:18 -07:00
HaoranYi 669bc43bcd
Buffer account's fields for hash (#33788)
* buffer accounts field for hash

* use smallvec to allocate hash buffer on stack

* sort deps

* more opt

* clippy

---------

Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-10-23 09:48:17 -05:00
Jeff Washington (jwash) a41b24f185
fix some ancient stats (#33791) 2023-10-23 07:23:47 -07:00
Jeff Washington (jwash) 34103e0913
typo in variable name (#33801) 2023-10-23 07:23:11 -07:00
Tao Zhu af9c754690
Crates have identical build.rs to frozen-abi can just be symlink (#33787)
crates have identical build.rs to frozen-abi can just be symlink
2023-10-21 13:33:10 -05:00
Jeff Washington (jwash) e13756133a
ancient: add many_refs_this_is_newest_alive (#33741)
* add many_refs_this_is_newest_alive

* fix pathological case, add comments

* add log

* update comments

* add log when we fail to pack

* use with_capacity

* fix log comment

* clippy
2023-10-20 09:55:37 -07:00
steviez c98c24bd6d
Revert "Split compute budget instructions process from struct itself … (#33784)
Revert "Split compute budget instructions process from struct itself (#33513)"

This reverts commit c73bebe984. This
was found to be a consensus breaking change.
2023-10-20 15:53:45 +02:00
Brooks ce8ad77373
Uses AccountHash in AppendVec (#33764) 2023-10-19 17:38:09 -04:00
Jeff Washington (jwash) f13c78b7c8
add ancient append vec test (#33762)
* add ancient append vec test

* Update accounts-db/src/ancient_append_vecs.rs

Co-authored-by: Brooks <brooks@prumo.org>

* add some comments

---------

Co-authored-by: Brooks <brooks@prumo.org>
2023-10-19 09:50:38 -07:00
Tao Zhu c73bebe984
Split compute budget instructions process from struct itself (#33513)
* Split compute budget instruction processing from ComputeBudget struct itself, allow compute_budget_instructions be processed elsewhere without having to instantiate ComputeBudget

* updated tests
2023-10-19 11:10:42 -05:00
Brooks 4e5c545e23
Uses AccountHash in tiered storage (#33763) 2023-10-19 11:52:36 -04:00
Brooks 0fcc0a0941
Returns AccountHash from get_filler_account() (#33758) 2023-10-18 20:29:40 -04:00
Brooks 1045548606
Uses AccountHash in StorableAccountsWithHashesAndWriteVersions (#33751) 2023-10-18 18:58:19 -04:00
Brooks 93d882f158
Moves solana-store-tool into the accounts-db crate (#33755) 2023-10-18 16:16:38 -04:00
Brooks 3a580f4df6
StorableAccounts::hash() returns &AccountHash (#33748) 2023-10-18 15:41:26 -04:00
Yueh-Hsuan Chiang 94273434ce
[TieredStorage] HotStorageReader::get_account_meta_from_offset() (#33724)
#### Problem
HotStorageReader currently only implements get_footer().  It does not
have a function to obtain the account meta.

#### Summary of Changes
This PR implements HotStorageReader::get_account_meta_from_offset().
A function that returns the account meta located at the specified offset.
This will be the helper function that will be later used to obtain the account
meta when the offset is available from the index block of a hot storage file. 

#### Test Plan
A new test is included in this PR.
2023-10-18 12:27:39 -07:00
Brooks e96678b302
Uses SeqLock for CachedAccountInner::hash (#33696) 2023-10-18 10:43:35 -04:00
Yueh-Hsuan Chiang 0b05e8db11
[TieredStorage] Footer test for HotStorageReader (#33718)
#### Problem
HotStorageReader currently doesn't have a test that covers its footer.

#### Summary of Changes
This PR includes a test for HotStorageReader that verifies the footer.
2023-10-17 15:24:38 -07:00
Jeff Washington (jwash) c09cbbb778
sort ancient append vec target_slots_sorted (#33729) 2023-10-17 14:49:46 -07:00
Jeff Washington (jwash) 56a7485998
log ancient stats each time we run (#33730) 2023-10-17 14:41:23 -07:00
HaoranYi 673a38c892
move timer after early exit (#33732)
Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-10-17 15:20:29 -05:00
HaoranYi f178975185
typo (#33734)
Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-10-17 14:45:17 -05:00
Jeff Washington (jwash) 5de9163625
add metric for ancient can't move slots (#33713)
* add metric for ancient can't move slots

* rename

* fix erors in replacing text

* rename
2023-10-17 08:34:18 -07:00
Jeff Washington (jwash) d948e5bf69
ancient shrink on its own cadence (#33712) 2023-10-16 10:06:20 -07:00
HaoranYi 167dac204f
Retry hash file allocation (#33565)
* retry hash file allocation

* add sleep

* submit a datapoint for retry

* typo

* more typos

* Update accounts-db/src/accounts_hash.rs

Co-authored-by: Brooks <brooks@prumo.org>

* fmt

---------

Co-authored-by: HaoranYi <haoran.yi@solana.com>
Co-authored-by: Brooks <brooks@prumo.org>
2023-10-16 09:21:08 -05:00
Jeff Washington (jwash) c354879a3f
stop padding new append vecs to page size (#33658)
* stop padding new append vecs to page size

* fix test

* fix another test

* for creating test accounts, allocate larger like we used to
2023-10-12 07:11:20 -07:00
HaoranYi 1a2c7f106e
fix typo in comments (#33665)
Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-10-12 09:05:10 -05:00
steviez 982d29cf60
Revert "stop padding new append vecs to page size (#33607)" (#33634)
This reverts commit b7962a3610.
2023-10-10 14:43:52 -05:00
Alexander Meißner cb695c7b32
Cleanup - Feature Gate of `enable_early_verification_of_account_modifications` (#33579)
Cleans up the feature gate of enable_early_verification_of_account_modifications:
- Removes PreAccount
- Removes InvokeContext::pre_accounts and InvokeContext::rent
- Removes InvokeContext::verify() and InvokeContext::verify_and_update()
- Removes TransactionContext::is_early_verification_of_account_modifications_enabled()
- Removes TransactionAccounts::is_early_verification_of_account_modifications_enabled
- No longer optional: TransactionContext::rent
2023-10-10 17:26:17 +02:00
Jeff Washington (jwash) b7962a3610
stop padding new append vecs to page size (#33607)
* stop padding new append vecs to page size

* for creating test accounts, allocate larger like we used to
2023-10-10 07:03:37 -07:00
Jeff Washington (jwash) 6c7d3c8aeb
remove redundant page_align (#33608) 2023-10-10 07:02:47 -07:00
Brooks fc73813db2
Adds AccountHash newtype (#33597) 2023-10-09 16:00:52 -04:00
Jeff Washington (jwash) 052677595c
in hash calc, delete old cache files that will not be used earlier (#33432)
* in hash calc, delete old cache files that will not be used earlier

* only delete if supposed to

* fmt
2023-10-09 11:47:39 -07:00
Brooks c924719040
Removes hash param from AccountsCache::store() (#33598) 2023-10-09 18:16:15 +00:00
HaoranYi 72574dac02
Assert acount hash mmap file capacity > 0 (#33575)
assert mmap capacity > 0

Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-10-09 09:38:00 -05:00
Brooks bb27bd88d4
Removes write version from tiered storage (#33566) 2023-10-06 16:19:35 -04:00
Yueh-Hsuan Chiang ecb1f8a9d7
[TieredStorage] Include Hot Account in StoredAccountMeta and ReadableAccount (#33544)
#### Problem
All account storage formats are required to implement both StoredAccountMeta
and ReadableAccount, but the implementation for the hot account format is missing.

#### Summary of Changes
This PR includes hot account format into StoredAccountMeta and ReadableAccount
enum.  This will allow the TieredStorageReader in the future PRs to return hot account
format in its `get_account` implementation.
2023-10-06 11:54:02 -07:00
Brooks c66af12bdb
Uses `IntSet` for `RemoveUnrootedSlotsSynchronization::slots_under_contention` (#33530) 2023-10-04 16:34:18 -04:00
Brooks 3b93041401
Uses `IntSet` for dead slots (#33529) 2023-10-04 16:21:44 -04:00
Brooks befc903993
Uses `IntSet` in AccountsDb::calc_delete_dependencies() (#33528) 2023-10-04 16:21:06 -04:00
Brooks f714a44c2a
Uses `IntSet` for `RollingBitField::excess` (#33523) 2023-10-04 15:04:28 -04:00
Brooks 5a9956824f
Uses `IntSet` for `RootsTracker::uncleaned_roots` (#33524) 2023-10-04 13:26:31 -04:00
Brooks d41fa346cc
Uses `IntSet` for `ShrinkCandidates` (#33522) 2023-10-04 13:07:35 -04:00
Brooks daaeb7410e
Adds solana-nohash-hasher (#33521) 2023-10-04 15:56:39 +00:00
HaoranYi bb19ebed49
Convert tuple into dedup result struct (#33450)
convert tupe into dedup result struct

Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-09-29 21:12:50 -05:00
Brooks 0e9e91c65e
Drops the shrink_candidate_slots lock after done inserting (#33459) 2023-09-29 16:58:55 +00:00
Brooks b81ff5d654
Fixup the metrics for remove_dead_accounts_shrink_us (#33458) 2023-09-29 16:04:33 +00:00
HaoranYi 6ea51280dd
Move sort timer out of loop (#33448)
move sort timer out of loop

Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-09-28 20:10:41 -05:00
HaoranYi 25c27d452c
hash dedup vec (#33246)
* hash_dedup vec algo

* reviews

* reviews

* more reviews

* simplify working_set init with add_next_item

* refactor to remove special case "new" from add_item.

The new change is that, even the new item is the new min, it will still be added to working_set.
This change will make init working_set code simpler and the loop loop check simpler.
Since the item is inserted in at the end of the vector, the cost of push into and pop from the working will be O(1), shouldn't affect performance much.

* comments

* refactor unnamed tuple in working set to SlotGroupPointer type

* use SlotGroupPointer in ItemLocation

* Add Copy traits to avoid explicty call of clone on SlotGroupPointer

* consume next in add_next_item fn (credit to jeff).

note that the old code is still correct, since before call to
add_next_item, we will have already overwritten `next` to correct value.

---------

Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-09-28 08:58:08 -05:00
Yihau Chen 3608378097
chore(solana-accounts-db): remove unused deps (#33429) 2023-09-27 16:27:40 +00:00
Yihau Chen ca92e9c387
chore(solana-accounts-db): remove unused deps (#33420) 2023-09-27 11:02:05 +00:00
HaoranYi e088eb2be0
Code clean up (#33417)
clean up

Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-09-26 22:35:25 +00:00
Yueh-Hsuan Chiang 746f69772a
[TieredStorage] Streamline the handling of TieredStorageFormat (#33396)
#### Problem
The TieredStorageFormat field in the TieredStorage is only used in the write path.

#### Summary of Changes
This PR simplifies the handling of TieredStorageFormat by removing its field from
TieredStorage struct but passing via write_accounts().
2023-09-26 14:05:36 -07:00
Brooks 9f6f532535
`flush_slot_cache_with_clean()` takes a single Slot (#33413) 2023-09-26 15:38:37 -04:00
Jeff Washington (jwash) a9b0fb492b
split hash calc ancient slot boundary to allow for ancient shrinking … (#33216)
split hash calc ancient slot boundary to allow for ancient shrinking to be behind
2023-09-26 07:27:50 -07:00
Brooks 23ad476ffb
Removes unused `Versioned` trait (#33360) 2023-09-25 17:18:38 -04:00
Jeff Washington (jwash) 40f536010f
visit_duplicate_pubkeys_during_startup uses scan (#33397) 2023-09-25 12:48:29 -07:00
Jeff Washington (jwash) 18231e9a5a
dump final startup index stats only after startup is complete (#33400) 2023-09-25 12:19:52 -07:00
Jeff Washington (jwash) 1b15464414
diskidx: stats for created vs reused (#33385) 2023-09-23 06:22:12 -07:00
Jeff Washington (jwash) 7cf71011fd
disk bucket: init restart path (#33375) 2023-09-22 11:40:46 -07:00
Trent Nelson 7c545b0ae9
bump rust stable to 1.72.1 (#33333)
* bump rust stable to 1.72.1

* bump rust nightly to 2023-09-20

* fix nightly lint -- unused doc comment

-- rustdoc does not generate documentation for expression fields

* fix nightly lint -- unnecessarily eager cloning of iterator items

* fix nightly lint -- loop never actually loops
2023-09-20 23:53:36 -06:00
Brooks 889d6c655e
Moves accounts-db benches to accounts-db crate (#33306) 2023-09-19 13:09:42 -04:00
HaoranYi c85eb73300
O(n) dedup (#33297)
O(N) dedup

Co-authored-by: jeff washington <jeff.washington@solana.com>
2023-09-18 17:55:28 -05:00
Tao Zhu 8b8a21a52f
cleanup feature: enable request heap frame instruction #30076 (#33243)
* cleanup feature: enable request heap frame instruction #30076

* update sbf tests

* removed out dated comments and test
2023-09-18 16:06:24 -05:00
Jeff Washington (jwash) 17c3930bc8
in gen index, stop using big hashmap (#33252)
* in gen index, stop using big hashmap

* update accounts_data_len

* remove approx_stored_count
2023-09-18 11:13:18 -07:00
Jeff Washington (jwash) 402981e3c1
cleanup test (#33291) 2023-09-18 10:59:42 -07:00
Jeff Washington (jwash) 27caf4d1d2
add test for duplicates in generate_index and fix approx stored count (#33290)
add test
2023-09-18 09:46:52 -07:00
steviez 9e11ae6275
Make program owners a const array instead of Vec<_> (#33275)
The program owners pubkeys are constant, no need to reconstruct the
Vec<Pubkey> and Vec<&Pubkey> each time this function runs (every time we
execute transactions).
2023-09-18 10:59:03 -05:00
Brooks 6283c1d568
Refactors out `unsafe` from cache_hash_data.rs (#33271) 2023-09-15 14:25:43 -04:00
Brooks a47f65d882
Refactors `unsafe` out of CacheHashDataFile's header (#33270) 2023-09-15 16:49:35 +00:00