Commit Graph

275 Commits

Author SHA1 Message Date
Pankaj Garg 10defb161f
SVM: Move TransactionErrorMetrics to SVM folder (#35112) 2024-02-06 11:15:48 -08:00
Pankaj Garg 99760e519a
SVM: move `inner_instructions_list_from_instruction_trace` to SVM (#35099)
SVM: move inner_instructions_list_from_instruction_trace to SVM
2024-02-06 08:38:24 -08:00
Dmitri Makarov ab30fb5f05
SVM: Move AccountOverrides from accounts-db to SVM (#35091) 2024-02-05 19:16:47 -05:00
Yueh-Hsuan Chiang 785dd2132e
[TieredStorage] Enable hot-storage in TieredStorage::write_accounts() (#35049)
#### Problem
While the implementation of hot-storage reader and writer
are mostly done, it is not yet connected to TieredStorage. 

#### Summary of Changes
This PR enables hot-storage in TieredStorage::write_accounts().

#### Test Plan
Completes the existing tests in TieredStorage to directly
write and read from a TieredStorage with the hot storage format.
2024-02-05 10:23:30 -08:00
HaoranYi 440c3bb156
Avoid account index entry Arc clone in shrinking (#35010)
* avoid account index entry Arc clone in shrink

* use scan to addref

* update code comments for scan fn

* expect

* warn

* update log message

---------

Co-authored-by: HaoranYi <haoran.yi@solana.com>
2024-02-05 16:47:00 +00:00
Brooks a16f982169
Removes redundant check on STORE_META_OVERHEAD (#35069) 2024-02-04 16:56:12 +00:00
Yueh-Hsuan Chiang 9935c2b5e7
[AppendVec] Use proper Vec initial size in append_accounts() (#35047)
#### Problem
append_accounts() only appends (len - skip) accounts.
However, AppendVec::append_accounts() reserves `len`
instead of `(len - skip)` for its vectors.

#### Summary of Changes
Use (len - skip) as the initial size of the Vectors.
2024-02-03 23:02:09 -08:00
Yueh-Hsuan Chiang dd30175e55
[TieredStorage] TieredStorageReader:: and HotStorageReader:: accounts() (#35031)
#### Problem
HotStorageReader and TieredStorageReader haven't implemented
accounts() that is required by AcocuntsFile.

#### Summary of Changes
This PR implements accounts() for both HotStorageReader
and TieredStorageReader

#### Test Plan
Extend the existing test to cover accounts().
2024-02-02 11:18:52 -08:00
Brooks 4b528e890c
Ensures STORE_META_OVERHEAD remains accurate (#35053) 2024-02-02 13:00:54 -05:00
Yueh-Hsuan Chiang 97d994ee6f
[TieredStorage] Use IndexOffset in TieredStorageMeta and get_account() (#35046)
#### Problem
TieredStorageMeta and TieredStorageReader::get_account API uses
u32 to represent IndexOffset.  However, within the TieredStorage scope,
IndexOffset should be used, it is not until working with AccountsFile API
when u32 representation of offset is needed.

#### Summary of Changes
Have TieredStorageMeta and TieredStorageReader to use IndexOffset.

#### Test Plan
Existing unit-tests.
2024-02-02 09:53:13 -08:00
Brooks f62293918d
Moves the async deleter code to accounts-db (#35040) 2024-02-02 09:21:26 -05:00
Yueh-Hsuan Chiang be9f17f053
[TieredStorage] Have HotStorageWriter::write_account() return Vec<StoredAccountInfo> (#34929)
#### Problem
To allow hot-storage to use HotStorageWriter::write_account() to
implement AccountsFile::append_accounts(), it is required to
provide a Vector of StoredAccountInfo to allow AccountsDB to
properly prepare the entry for each account.

#### Summary of Changes
This PR enables HotStorageWriter::write_account() to return
Vec<StoredAccountInfo>.

#### Test Plan
Extend existing tests for HotStorageWriter to verify the correctness
of the returned Vec<StoredAccountInfo>.
2024-02-01 13:33:42 -08:00
Brooks daa2449ad4
Removes RwLock on AccountsDb::shrink_paths (#35027) 2024-02-01 09:35:34 -05:00
Brooks 0569304835
Replaces bare Arc::default() in CacheHashData::new() (#35017) 2024-01-31 10:52:59 -05:00
Yueh-Hsuan Chiang 16a2f1bd3d
[TS] Add get_account() and account_matches_owner() to TieredStorageReader (#34968)
#### Problem
TieredStorageReader is a wrapper enum that works for
both Hot and Cold storage readers, but its get_account()
and account_matches_owner() API are missing.

#### Summary of Changes
Add get_account() and account_matches_owner() to
TieredStorageReader.

#### Test Plan
hot.rs offers similar coverage for HotStorageReader.
2024-01-29 11:05:47 -08:00
Brooks b9815da6cc
Fixes typo (#34990) 2024-01-28 17:32:09 -05:00
Pankaj Garg 0d117d420c
Remove BlockhashQueue dependency from SVM related code (#34974) 2024-01-26 13:46:44 -08:00
HaoranYi e38848e519
Remove unused get_append_vec_id function (#34949)
remove unused get_append_vec_id fn

Co-authored-by: HaoranYi <haoran.yi@solana.com>
2024-01-26 21:41:09 +00:00
Yueh-Hsuan Chiang 3380c14044
[TieredStorage] Correct the HotStorage API for account_matches_owners (#34967)
#### Problem
In HotStorageReader, the account_matches_owners takes
&[&Pubkey] as the address candidates.  However, it should
be &[Pubkey] as defined in the accounts_file API.

#### Summary of Changes
Correct HotStorageReader::account_matches_owners() to
take &[Pubkey] instead.

#### Test Plan
Existing unit-tests
2024-01-26 09:40:05 -08:00
Yueh-Hsuan Chiang 7138f8767e
[TieredStorage] Avoid AccountHash copy in AccountMetaOptionalFields (#34969)
#### Problem
Using non-reference type of AccountHash in 
AccountMetaOptionalFields causes an unnecessary copy
as mentioned in #34948.

#### Summary of Changes
Uses &AccountHash in AccountMetaOptionalFields to
avoid copying.

#### Test Plan
Existing unit tests.

Fixes #34948
2024-01-26 09:13:09 -08:00
Yueh-Hsuan Chiang 663a1bb8f4
[TieredStorage] Write owners block for HotAccountStorage (#34927)
#### Problem
So far the current HotStorageWriter::write_accounts() only writes
accounts blocks and index block.

#### Summary of Changes
The PR further writes owners block in HotStorageWriter::write_accounts().

#### Test Plan
Extended existing test for HotStorageWriter to cover the owners block.
2024-01-26 06:48:28 -08:00
Yueh-Hsuan Chiang 51c0649af8
[TieredStorage] Use RENT_EXEMPT_RENT_EPOCH in HotStorageWriter (#34950)
#### Problem
In HotStorageWriter::write_accounts, it skips storing rent-epoch when
the rent-epoch equals Epoch::MAX.  While the value is correct, it is
more suitable to use RENT_EXEMPT_RENT_EPOCH instead as the
goal here is to save bytes for rent-exempt accounts.

#### Summary of Changes
Replace Epoch::MAX by RENT_EXEMPT_RENT_EPOCH when checking
whether to skip storing rent-epoch in HotStorageWriter.
2024-01-25 17:17:24 -08:00
Brooks f0d67d7f28
Adds hit/miss stats for cache hash data (#34954) 2024-01-25 17:27:45 -05:00
Brooks e155d9c445
Adds cache hash data deletion policy enum (#34956) 2024-01-25 16:58:56 -05:00
Yueh-Hsuan Chiang 26d62b9516
[TieredStorage] writing hot account blocks and index blocks (#34828)
#### Problem
The implementation of write_accounts() for HotAccountStorage is missing.
It consists of the writing of account blocks, index block, and owners block.

#### Summary of Changes
This PR completes part of the HotStorageWriter::write_accounts().
Specifically, it finishes the writing of account blocks and index block.

#### Test Plan
A new unit-test is added to verify the correctness of the work-in-progress
HotStorageWriter::write_accounts().
2024-01-25 09:38:06 -08:00
Brooks 5898b9a2f7
Cleans up stale accounts hash cache files (#34933) 2024-01-24 15:31:50 -05:00
Dmitri Makarov ef233eaaa7
Refactor load_accounts to take a reference to a slice instead of vec (#34919)
This is in preparation for further refactoring of
Bank::load_and_execute_transactions in a separate commit.
2024-01-24 09:43:18 -05:00
Yueh-Hsuan Chiang 1810feadc2
[TieredStorage] In-memory struct for writing OwnersBlock (#34853)
#### Problem
To write the owners-block, it requires an in-memory struct that maintains
a set of unique owner addresses while providing a look-up function to
obtain the OwnerOffset with the specified owner address. 

#### Summary of Changes
This PR adds OwnersTable, the in-memory struct that maintains
a set of unique owner addresses while providing a look-up function to
obtain the OwnerOffset with the specified owner address.

#### Test Plan
A new unit-test is added.
2024-01-23 14:57:53 -08:00
Brooks 8ff511e8fa
Moves create_and_canonicalize_directories() into accounts-db utils (#34882) 2024-01-23 06:46:27 -05:00
Brooks 2f744f1639
Moves create_all_accounts_run_and_snapshot_dirs() into accounts-db utils (#34877) 2024-01-22 18:18:43 -05:00
Brooks d005b3a5b8
Removes fs-err dependency from accounts-db crate (#34869) 2024-01-22 06:55:13 -05:00
Brooks 3916c31cb4
Replaces fs-err in tiered storage (#34859) 2024-01-19 17:16:56 -05:00
Brooks 3eb06b4b37
Replaces fs-err in accounts-db (#34860) 2024-01-19 16:35:02 -05:00
Yueh-Hsuan Chiang 81b3210eec
[TieredStorage] Code refactoring for OwnersBlock (#34854)
#### Problem
The OwnersBlockFormat is currently defined inside footer.rs
instead of inside owners.rs.  In addition, the implementation of
OwnersBlock doesn't honor OwnersBlockFormat.

#### Summary of Changes
This PR moves OwnersBlockFormat from footer.rs to owners.rs
and repurpose OwnersBlock as OwnersBlockFormat (just like
the IndexBlockFormat inside index.rs)

#### Test Plan
Existing unit-tests.
2024-01-19 08:15:25 -08:00
steviez 3dd348802f
Bubble up genesis load errors instead of exiting (#34851)
The function open_genesis_config() performs several operations that
could fail. If any of these fail, the process exits immediately.

Instead of exiting immediately, bubble up the error and let the caller
decide the appropriate action. solana-validator and solana-ledger-tool
will functionally be unchanged, but this consolidates startup failures
for both of these processes.
2024-01-19 10:25:46 -05:00
Yueh-Hsuan Chiang 3fa44e6fbe
[TieredStorage] Include executable field into AccountMetaFlags (#34724)
#### Problem
Before we have fully switched to the new way to determine whether
an account is executable, we still need a bit for th executable flag at
this moment in the TieredStorage as well as for backward compatibility
in case we want to revert it back.

#### Summary of Changes
This PR adds the executable flag into AccountMetaFlags.

#### Test Plan
Updated existing tests for AccountMetaFlags to cover executable flag.
2024-01-16 11:25:57 -08:00
Andrew Fitzgerald 95f888ab54
Unlock only if lock_result was Ok (#34652) 2024-01-09 08:19:25 -08:00
Yueh-Hsuan Chiang 2082f8b3ca
[TieredStorage] HotStorageWriter::new() (#34659)
#### Problem
The implementation of HotAccountWriter is missing.

#### Summary of Changes
This PR kicks off the implementation of HotStorageWriter by
adding HotStorageWriter::new().

#### Test Plan
Add a new unit-test that verifies the correctness of HotStorageWriter
writing zero accounts using HotStorageReader.
2024-01-08 14:14:30 -08:00
Yueh-Hsuan Chiang 3a2f1320c5
[TieredStorage] Rename AddressAndBlockOffsetOnly to AddressesThenOffsets (#34658)
#### Problem
In the previous refactoring, IndexBlockFormat::AddressAndBlockOffsetOnly
can now work independently with the AccountMetaFormat.  As a result,
the naming of this format should be updated to reflect this.

#### Summary of Changes
As the format first persists the list of addresses followed by the list of offsets,
this PR renames AddressAndBlockOffsetOnly to AddressesThenOffsets.
2024-01-08 13:10:37 -08:00
Brooks e4ec68d704
clippy: accounts-db lints (#34628)
```
warning: this `let...else` may be rewritten with the `?` operator
  --> accounts-db/src/rolling_bit_field/iterators.rs:36:13
   |
36 | /             let Some(bit) = self.bit_range.next() else {
37 | |                 return None;
38 | |             };
   | |______________^ help: replace it with: `let bit = self.bit_range.next()?;`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#question_mark
   = note: `#[warn(clippy::question_mark)]` on by default

    Checking solana-rpc-client-api v1.18.0 (/Users/brooks/src/solana/rpc-client-api)
warning: `solana-accounts-db` (lib) generated 1 warning
```
2024-01-03 14:17:12 +00:00
Nick Frostbutter fc2a8794be
[docs] updated readme and fix links (#34565)
* feat: updated readme

* fix: updated links

* fix: proposal links

* fix: more links

* fix: json-rpc links

* fix: more links

* fix: zk links

* fix: managing forks

* fix: links for deprecated methods
2024-01-03 09:06:06 -05:00
Yueh-Hsuan Chiang d500eb6510
[TieredStorage] HotAccountsReader::get_account (#34499)
#### Problem
All structs that implement AccountsFile are required to support get_account,
but the implementation for HotAccounts is currently missing.

#### Summary of Changes
This PR implements HotAccountsReader::get_account_from_index_offset.
This will allow it to support AccountsFile::get_account API.

#### Test Plan
Add new unit-test.
2023-12-25 06:44:00 -08:00
Yueh-Hsuan Chiang 5b26d2737b
[TieredStorage] Fix typos in index.rs (#34546)
#### Problem
There're some typos in the comments and assert messages index.rs mentioned in #34529

#### Summary of Changes
Fix the typos (only in assert message and comments).
2023-12-21 22:36:38 -08:00
Yueh-Hsuan Chiang f73fd9dd3c
[TieredStorage] HotStorageReader::account_matches_owners (#34350)
#### Problem
Each AccountsFile is required to implement account_matches_owners(),
a public API that checks whether the account located at the specified
offset matches any input owners.  However, the implementation of
account_matches_owners() for HotAccountsStorage is missing.

#### Summary of Changes
This PR implements HotStorageReader::account_matches_owners().

#### Test Plan
A new unit-test is added to this PR.
2023-12-21 19:20:03 -08:00
Yueh-Hsuan Chiang a583035812
[TieredStorage] Boundary check for get_account_offset() (#34531)
#### Problem
TieredStorage doesn't perform boundary check in get_account_offset
when the input IndexOffset isn't valid.

#### Summary of Changes
This PR adds two checks.  First, it checks whether the IndexOffset exceeds
the boundary of the index block.  Second, when an index format that has the
same index entries as account entries is used, it also checks whether IndexOffset
is smaller than account_entry_count.

#### Test Plan
Two new tests are added to this PR.
2023-12-21 12:52:15 -08:00
GoodDaisy 03386cc7b9
Fix typos (#34459)
* Fix typos

* Fix typos

* fix typo
2023-12-21 13:06:00 -07:00
Yueh-Hsuan Chiang 09efd704eb
[TieredStorage] boundary check for get_account_address() (#34529)
#### Problem
get_account_address() does not check whether IndexOffset is valid.

#### Summary of Changes
This PR adds two checks.  First, it checks whether the IndexOffset exceeds
the boundary of the index block.  Second, when an index format that has the
same index entries as account entries is used, it also checks whether IndexOffset
is smaller than account_entry_count.

#### Test Plan
New unit-test is added.
2023-12-20 10:44:34 -08:00
Yueh-Hsuan Chiang eb948b1ddc
[TieredStorage] Boundary check for accessing hot account meta (#34349)
#### Problem
Hot accounts are stored in accounts blocks, whose offset is smaller than
the index block offset.  However, the current code doesn't perform
any boundary checks when accessing hot account meta.

#### Summary of Changes
Adds boundary check when accessing hot account meta.
2023-12-18 14:32:41 -08:00
Brooks e858a5a7c0
Removes unnecessary new_sized() AccountsDb ctor (#34504) 2023-12-18 16:39:57 -05:00
Brooks 4181ea4677
Removes unnecessary AccountsDb::new_with_config_for_benches() (#34484) 2023-12-18 06:52:41 -05:00