Commit Graph

204 Commits

Author SHA1 Message Date
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
Brooks f77b3d9389
Derives Pod for CalculateHashIntermediate (#33267) 2023-09-15 12:47:38 -04:00
Brooks 4c42413c1f
Refactors out `unsafe` from MmapAccountHashesFile::read() (#33266) 2023-09-15 15:09:01 +00:00
Jeff Washington (jwash) 3ad8394047
stop removing empty bins during index generation (#33242) 2023-09-14 07:53:33 -07:00
Jeff Washington (jwash) 886eabd74d
gen idx: refactor StorageSizeAndCount population (#33244) 2023-09-14 07:53:05 -07:00
Jeff Washington (jwash) 602f0f6ecb
generate index: fn arg: &Slot -> Slot (#33229)
fn arg: &Slot -> Slot
2023-09-13 14:14:30 -07:00
Jeff Washington (jwash) c2bf2a969d
remove unused metrics (#33241) 2023-09-13 14:14:10 -07:00
Jeff Washington (jwash) cb310a310a
set approx store count at generate index time (#33240) 2023-09-13 14:13:46 -07:00
Jeff Washington (jwash) 093ae61e85
single pass through each storage to populate info (#33227) 2023-09-13 12:37:01 -07:00
Jeff Washington (jwash) 3ffd78f2d7
add comments (#33226) 2023-09-12 13:51:27 -07:00
Brooks 21e7f98b3a
Uses hex for the hash in accounts hash cache file names (#33196) 2023-09-12 11:26:08 -04:00
Brooks c61ee20b44
Transient accounts hash cache dir is unnecessary (#33181) 2023-09-12 11:23:07 -04:00
HaoranYi 3cd3994939
clean up pub crate (#33214)
Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-09-11 19:28:26 -05:00
Brooks 09936aac0e
Removes `new()` from POD CalculateHashIntermediate and CumulativeOffset (#33211) 2023-09-11 22:33:25 +00:00
HaoranYi cf35799b2a
remove unused stats (#33213)
Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-09-11 21:03:37 +00:00
Brooks 659fc6837b
Removes `pub` from accounts_hash.rs items (#33209) 2023-09-11 20:49:51 +00:00
Jeff Washington (jwash) d724af863c
add a few accounts hash dedup tests (#33208) 2023-09-11 13:20:28 -07:00
Brooks 6298c6c31e
Shares accounts hash cache data between full and incremental (#33164) 2023-09-11 15:55:48 -04:00
Alexander Meißner bbb57be0a5
Refactor - Move interfaces of address-lookup-table into the program SDK (#33165)
* Adds a module `address_lookup_table` to the SDK.

* Adds a module `address_lookup_table::instruction` to the SDK.

* Adds a module `address_lookup_table::error` to the SDK.

* Adds a module `address_lookup_table::state` to the SDK.

* Moves AddressLookupTable into SDK as well.

* Moves AddressLookupTableAccount into address_lookup_table.

* Adds deprecation messages.

* Disentangles dependencies across cargo files.
2023-09-11 21:10:40 +02:00
Jeff Washington (jwash) 4dfe62a2f0
rework accounts hash calc dedup to avoid kernel file error (#33195)
* in hash calc, calculate max_inclusive_num_pubkeys

* in hash calc, dedup uses mmap files to avoid os panic

* as_mut_ptr

* remove unsafe code

* refactor count in hash files

---------

Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-09-11 10:57:21 -07:00
Jeff Washington (jwash) a145ade564
stat for time spent copying generate index contents (#33187)
* stat for time spent copying generate index contents

* rework to move stat to generate_index

* fix fmt
2023-09-08 12:55:54 -07:00
Jeff Washington (jwash) dc6b1eb653
in shrink, get stores prior to shrink starting (#33194) 2023-09-08 08:45:32 -07:00
Jeff Washington (jwash) 0083e426b2
ShrinkCandidates only holds slot (#33173) 2023-09-07 12:28:05 -07:00
Jeff Washington (jwash) e331275178
remove coupling of ShrinkCandidates to HashMap (#33176) 2023-09-07 09:07:37 -07:00
Brooks f4816dc0cf
Moves CacheHashData test-only methods into tests module (#33170) 2023-09-06 15:25:58 -04:00
Brooks a3dc3eb37c
Takes inner HashSet when dropping CacheHashData (#33169) 2023-09-06 18:19:01 +00:00
behzad nouri 88ee8f5820
replaces once_cell::sync::OnceCell with std::sync::OnceLock (#33140)
std::sync::OnceLock has become stable since rust 1.70.0 and there is no
longer a need for an external crate dependency.
2023-09-06 16:46:51 +00:00
HaoranYi a8bc6ebe38
Use `write_all` for binned account hash file writes (#33095)
write_all

Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-09-06 11:03:05 -05:00
Illia Bobyr d077b13efa
accounts-db: test_hash_stored_account: Avoid UB. (#33083)
unsafe { transmute }` in the test is generating undefined behavior, as it
assigns a value into `bool` that is neither 0 nor 1.

We see discrepancy between release and debug builds due to this.

It is better to avoid `unsafe` blocks if there alternatives that let the
compiler check everything.
2023-09-05 20:30:17 -07:00
Jeff Washington (jwash) fb1ba216f5
Revert "Add an RPC API that can query the list of Top N secondary index keys and their sizes (#28887)" (#33121)
* Revert "Add an RPC API that can query the list of Top N secondary index keys and their sizes (#28887)"

This reverts commit 1e3d6349aa.

* Revert "Add Admin RPC Front End for Top N Secondary Index Key Sizes Query. (#29352)"

This reverts commit aa353e4b83.

* fix test uses

* fmt
2023-09-01 14:36:06 -07:00
Brooks d1b849972f
Support a custom path for the accounts hash cache (#33115) 2023-09-01 15:29:56 -04:00
Jeff Washington (jwash) 255029f61a
add rate info to generate index log (#33108) 2023-09-01 11:40:00 -07:00
Alessandro Decina 16ea141402
sdk: put AccountSharedData::set_data() behind feature="dev-context-only-utils" (#33086)
set_data() is deprecated in favor of set_data_from_slice().
2023-09-01 21:02:14 +07:00
Alexander Meißner 9e703f85de
Upgrades Rust to 1.72.0 & nightly-2023-08-25 (#32961)
* allow pedantic invalid cast lint

* allow lint with false-positive triggered by `test-case` crate

* nightly `fmt` correction

* adapt to rust layout changes

* remove dubious test

* Use transmute instead of pointer cast and de/ref when check_aligned is false.

* Renames clippy::integer_arithmetic to clippy::arithmetic_side_effects.

* bump rust nightly to 2023-08-25

* Upgrades Rust to 1.72.0

---------

Co-authored-by: Trent Nelson <trent@solana.com>
2023-09-01 07:26:13 +00:00
Ryo Onodera 4fe0812f3c
Make should_panic tests compatible with 1.73+ panic format (#33099)
* Adjust should_panic tests for 1.73+ panic format

* Update more panic format change affected tests...
2023-09-01 02:04:22 +00:00
HaoranYi c87f9cdfc9
use shift for pubkey to bin calculation (#33090)
Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-08-31 15:04:25 -05:00
Jeff Washington (jwash) 9a7d503fe4
rework sorting during generate_index (#33076)
* drag data len around during generate_index

* fix tests

* update comments
2023-08-31 12:51:56 -07:00
Brooks 5e26b05597
Removes the "unpacked entries so far" log at startup (#33093) 2023-08-31 15:29:12 -04:00
Ryo Onodera 92a0b310c1
Add #[repr(C)] for more future-proof byte mangling (#33085)
* Add #[repr(C)] for more future-proof byte manglng

* Improve comments after code-review
2023-08-31 22:48:24 +09:00
Jeff Washington (jwash) 1b9c9a313c
reorder generate_index info (#33077)
reorder generateindex info
2023-08-30 16:16:40 -07:00
behzad nouri 4ec5ea6f7b
replaces assert!(matches!(...)) with assert_matches!(...) (#33068)
assert_matches!(...) provides more informative error message when it
fails and it is part of nightly rust:
https://doc.rust-lang.org/std/assert_matches/macro.assert_matches.html
2023-08-30 13:48:27 -04:00
Jeff Washington (jwash) 48f27d5e73
add stats for generate_index (#33061) 2023-08-30 06:43:27 -07:00
Trent Nelson b8dc5daedb
preliminaries for bumping nightly to 2023-08-25 (#33047)
* remove unnecessary hashes around raw string literals

* remove unncessary literal `unwrap()`s

* remove panicking `unwrap()`

* remove unnecessary `unwrap()`

* use `[]` instead of `vec![]` where applicable

* remove (more) unnecessary explicit `into_iter()` calls

* remove redundant pattern matching

* don't cast to same type and constness

* do not `cfg(any(...` a single item

* remove needless pass by `&mut`

* prefer `or_default()` to `or_insert_with(T::default())`

* `filter_map()` better written as `filter()`

* incorrect `PartialOrd` impl on `Ord` type

* replace "slow zero-filled `Vec` initializations"

* remove redundant local bindings

* add required lifetime to associated constant
2023-08-29 23:05:35 +00:00
Jeff Washington (jwash) 00bfc6abd3
remove unused previous_uncleaned_roots (#33033) 2023-08-29 14:54:17 -07:00
Jeff Washington (jwash) 4d452fc5e9
update lru for read only cache if it has been long enough since last access (#32560)
* update lru for read only cache if it has been long enough since last access

* update comment

* use acq/rel
2023-08-29 10:37:55 -07:00
HaoranYi 555741e4d6
Refactor total_items, bin_min/max size calcualtion (#33034)
refactor total_items, bin_min/max size calcuation

Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-08-29 10:37:25 -05:00
Jeff Washington (jwash) 9bc09c9610
get unique keys while finding dups (#33039)
* get unique keys while finding dups

* pr feedback
2023-08-29 15:06:35 +00:00
Jeff Washington (jwash) 97d6e6f738
move uncleaned roots code to test mod (#33029) 2023-08-28 14:01:27 -07:00
Jeff Washington (jwash) ce71461bad
remove unused return value from reset_uncleaned_roots (#33030) 2023-08-28 13:17:52 -07:00
Jeff Washington (jwash) 35bd2df0a6
speedup populate_and_retrieve_duplicate_keys_from_startup (#33013) 2023-08-28 10:20:29 -07:00
Jeff Washington (jwash) f4dcb20d2e
add overall measurement for generating index (#33008) 2023-08-28 08:40:54 -07:00
Alexander Meißner a8be70fa7a
General cleanup (#32980)
* Fixes `cargo::` in build.rs

* Fixes overshadowing reexports.

* Removes unnecessary `as *const u8`.

* Removes unnecessary `.into_iter()`.

* cargo clippy
2023-08-24 21:44:19 +02:00
Jon Cinque 0fe902ced7
Bump rand to 0.8, rand_chacha to 0.3, getrandom to 0.2 (#32871)
* sdk: Add concurrent support for rand 0.7 and 0.8

* Update rand, rand_chacha, and getrandom versions

* Run command to replace `gen_range`

Run `git grep -l gen_range | xargs sed -i'' -e 's/gen_range(\(\S*\), /gen_range(\1../'

* sdk: Fix users of older `gen_range`

* Replace `hash::new_rand` with `hash::new_with_thread_rng`

Run:
```
git grep -l hash::new_rand | xargs sed -i'' -e 's/hash::new_rand([^)]*/hash::new_with_thread_rng(/'
```

* perf: Use `Keypair::new()` instead of `generate`

* Use older rand version in zk-token-sdk

* program-runtime: Inline random key generation

* bloom: Fix clippy warnings in tests

* streamer: Scope rng usage correctly

* perf: Fix clippy warning

* accounts-db: Map to char to generate a random string

* Remove `from_secret_key_bytes`, it's just `keypair_from_seed`

* ledger: Generate keypairs by hand

* ed25519-tests: Use new rand

* runtime: Use new rand in all tests

* gossip: Clean up clippy and inline keypair generators

* core: Inline keypair generation for tests

* Push sbf lockfile change

* sdk: Sort dependencies correctly

* Remove `hash::new_with_thread_rng`, use `Hash::new_unique()`

* Use Keypair::new where chacha isn't used

* sdk: Fix build by marking rand 0.7 optional

* Hardcode secret key length, add static assertion

* Unify `getrandom` crate usage to fix linking errors

* bloom: Fix tests that require a random hash

* Remove some dependencies, try to unify others

* Remove unnecessary uses of rand and rand_core

* Update lockfiles

* Add back some dependencies to reduce rebuilds

* Increase max rebuilds from 14 to 15

* frozen-abi: Remove `getrandom`

* Bump rebuilds to 17

* Remove getrandom from zk-token-proof
2023-08-21 19:11:21 +02:00
Jeff Washington (jwash) 524274d8b5
update comment (#32919) 2023-08-21 10:04:37 -07:00
Brooks c6989189ef
Renames CalcAccountsHashFlavor to CalcAccountsHashKind (#32905) 2023-08-21 15:41:07 +00:00
Brooks a563b4cccb
Renames AccountsHashEnum to AccountsHashKind (#32904) 2023-08-21 10:34:56 -04:00
Jeff Washington (jwash) a7d340538e
cache hash files: separate get_file_reference_to_map_later and map (#32891) 2023-08-21 07:30:29 -07:00
Brooks e28c819819
Add docs to load_by_program_slot() (#32896) 2023-08-18 19:11:42 -04:00
Yueh-Hsuan Chiang 66b72a61be
TieredStorage struct (5/N) -- tests for write_accounts (#32850)
#### Problem
Having a PR that is self-contained with a big picture while having it testable
for TieredStorage::write_accounts is challenging, as it requires all the write-side
code, read-side code, and test code.

#### Summary of Changes
This PR solves part of the problem by having one dedicated PR for tests.
Specifically, it includes test utils that allow us to generate test accounts,
invoke write_accounts, and verify the written tiered-storage instance.

With this PR, it will be easier to write future PRs. 

#### Test Plan
A new set of unit-tests and test utils is included in this PR.
2023-08-18 11:29:53 -07:00
Jeff Washington (jwash) 48e51134d7
refactor cache hash data stats (#32884) 2023-08-18 09:24:59 -07:00
Jeff Washington (jwash) 7d203722cb
remove clone() (#32885) 2023-08-18 08:18:32 -07:00
Jeff Washington (jwash) 9499d3d2f8
move `map` to `CacheHashDataFileReference` (#32883)
refactor cache hash data map
2023-08-18 08:12:08 -07:00
Jeff Washington (jwash) 1693af8e68
minor cleanup to read only accounts cache (#32876) 2023-08-18 07:07:40 -07:00
Jeff Washington (jwash) ac6523c373
refactor cache hash data files (#32877) 2023-08-18 07:01:01 -07:00
Jeff Washington (jwash) 9260c0f645
move invariant code outside loop (#32837) 2023-08-17 15:28:04 -07:00
Ryo Onodera e700dde617
dcou: Update qualifier_attr to 0.2.2 (#32838)
Update qualifier_attr to 0.2.2
2023-08-15 13:10:47 +00:00
Brooks e316db2ab4
dcou: set_accounts_hash() (#32829) 2023-08-15 07:18:59 -04:00
steviez 6bbf514e78
Add ability to output components that go into Bank hash (#32632)
When a consensus divergance occurs, the current workflow involves a
handful of manual steps to hone in on the offending slot and
transaction. This process isn't overly difficult to execute; however, it
is tedious and currently involves creating and parsing logs.

This change introduces functionality to output a debug file that
contains the components go into the bank hash. The file can be generated
in two ways:
- Via solana-validator when the node realizes it has diverged
- Via solana-ledger-tool verify by passing a flag

When a divergance occurs now, the steps to debug would be:
- Grab the file from the node that diverged
- Generate a file for the same slot with ledger-tool with a known good
  version
- Diff the files, they are pretty-printed json
2023-08-15 00:12:05 -05:00
Brooks ce57cac370
Use update_accounts_hash() in AccountsHashVerifier (#32830) 2023-08-14 13:11:23 -04:00
HaoranYi bf77a6c7f2
Fix write cache size grow/shrink bug (#32788)
fix write cache size bug

Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-08-14 10:11:09 -07:00
Jeff Washington (jwash) 9212ac347c
accounts hash sort_slot_storage_scan sorts in place (#32810) 2023-08-14 07:47:33 -07:00
Ryo Onodera ce63640d6d
dcou: make internal function `pub` conditionally (#32822)
dcou: make internal function pub conditionally
2023-08-13 14:12:20 +09:00
Jeff Washington (jwash) 4e6fb8e343
removed unused accounts hash code (#32791) 2023-08-11 06:49:07 -07:00
HaoranYi d26e3ff22b
Extract read-only cache stats (#32789)
* extract read-only cache stat

* rename stats

---------

Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-08-10 13:42:09 -05:00
Jeff Washington (jwash) c9f7cb5b7e
keep active stats lock held (#32763) 2023-08-10 08:56:00 -07:00
Brooks 6ff390802b
Uses fold+reduce in de_dup_accounts() (#32765) 2023-08-09 17:27:04 -04:00
Pankaj Garg f4287d70bb
Move accounts-db code to its own crate (#32766) 2023-08-09 13:03:36 -07:00