Commit Graph

1095 Commits

Author SHA1 Message Date
Pankaj Garg 9d42cd7efe
Initialize fork graph in program cache during bank_forks creation (#33810)
* Initialize fork graph in program cache during bank_forks creation

* rename BankForks::new to BankForks::new_rw_arc

* fix compilation

* no need to set fork_graph on insert()

* fix partition tests
2023-10-23 09:32:41 -07:00
Ryo Onodera 5a963529a8
Add BankWithScheduler for upcoming scheduler code (#33704)
* Add BankWithScheduler for upcoming scheduler code

* Remove too confusing insert_without_scheduler()

* Add doc comment as a bonus

* Simplify BankForks::banks()

* Add derive(Debug) on BankWithScheduler
2023-10-21 15:56:43 +09:00
Alexander Meißner a5c7c999e2
Bump solana_rbpf to v0.8.0 (#33679)
* Bumps solana_rbpf to v0.8.0

* Adjustments:
Replaces declare_syscall!() with declare_builtin_function!().
Removes Config::encrypt_runtime_environment.
Simplifies error propagation.
2023-10-20 21:39:50 +02:00
Pankaj Garg 59cb3b57ee
Set a global fork graph in program cache (#33776)
* Set a global fork graph in program cache

* fix deadlock

* review feedback
2023-10-20 08:47:03 -07:00
steviez 383aef218d
Make Blockstore populate TransactionStatusIndex entries (#33756)
A previous change removed logic that populated the
TransactionStatusIndex entries at each of the legacy primary index keys
(0 and 1). While these entries will not be read or written in the
future, these entries are necessary for backwards compatibility. Namely,
branches <= v1.17 expect these entries to be present and .unwrap()'s
could fail if they are not.

So, add the initialization of these entries back into Blockstore logic.
We can remove initialization of these entries once our stable and beta
branches are both versions that do not expect these entries to be
present (should be v1.18).
2023-10-19 23:28:53 +02:00
Tyera 01a3b1b52f
Blockstore: clean/save old TransactionMemos sensibly (#33678)
* Convert OldestSlot to named struct

* Add clean_slot_0 to OldestSlot

* Set AtomicBool to true when all primary-index keys returning slot 0 should be purged

* Add PurgedFilter::clean_slot_0

* Use clean_slot_0 to preserve deprecated TransactionMemos

* Also set AtomicBool to true immediately on boot, if highest_primary_index_slot.is_none

* Add test

* Fixup test
2023-10-12 22:43:27 -06:00
Brooks 452fd5d384
Adds `--no-skip-initial-accounts-db-clean` *hidden* CLI flag (#33664) 2023-10-12 13:32:40 -04:00
Tyera d286c00a30
Blockstore: track when all primary-index data has been purged (#33668)
* Fix typo

* Add Blockstore::highest_primary_index_slot

* Add getter

* Populate highest_primary_index_slot on boot

* Wipe highest_primary_index_slot when surpassed by oldest_slot

* Update highest_primary_index_slot in exact purge

* Return indexes early if highest_primary_index_slot has been cleared

* Limit read_transaction_status based on highest_primary_index_slot

* Limit read_transaction_memos based on highest_primary_index_slot

* Use highest_primary_index_slot to add early return to get_transaction_status_with_counter

* Fixup tests

* Use existing getter for highest_primary_index_slot

Co-authored-by: steviez <stevecz@umich.edu>

---------

Co-authored-by: steviez <stevecz@umich.edu>
2023-10-12 07:12:33 +00:00
steviez 6009d49cc3
Remove dummy entries in Blockstore special columns (part 2) (#33649)
* Always call initialize_transaction_status_index() at startup,
  doing so will ensure dummy entries are actually cleaned
* Rename initialize_transaction_status_index()
* Stop initializing TransactionStatusIndex column entries, these
  are no longer needed and old software will initialize if needed
2023-10-11 13:13:10 -05:00
steviez 33e1dd71f3
Remove dated Blockstore PurgeType::PrimaryIndex code (#33631)
* Update instances of PurgeType::PrimaryIndex to PurgeType::Exact
* Remove now unused functions
* Remove unused active_transaction_status_index field
2023-10-10 16:35:42 -05:00
Tyera 509d6acd2b
Remove primary index from Blockstore special-column keys (#33419)
* Add helper trait for column key deprecation

* Add WriteBatch::delete_raw

* Add ProtobufColumn::get_raw_protobuf_or_bincode

* Add ColumnIndexDeprecation iterator methods

* Impl ColumnIndexDeprecation for TransactionStatus (doesn't build)

* Update TransactionStatus put

* Update TransactionStatus purge_exact

* Fix read_transaction_status

* Fix get_transaction_status_with_counter

* Fix test_all_empty_or_min (builds except tests)

* Fix test_get_rooted_block

* Fix test_persist_transaction_status

* Fix test_get_transaction_status

* Fix test_get_rooted_transaction

* Fix test_get_complete_transaction

* Fix test_lowest_cleanup_slot_and_special_cfs

* Fix test_map_transactions_to_statuses

* Fix test_transaction_status_protobuf_backward_compatability

* Fix test_special_columns_empty

* Delete test_transaction_status_index

* Delete test_purge_transaction_status

* Ignore some tests until both special columns are dealt with (all build)

* Impl ColumnIndexDeprecation for AddressSignatures (doesn't build)

* Add BlockstoreError variant

* Update AddressSignatures put

* Remove unneeded active_transaction_status_index column lock

* Update AddressSignatures purge_exact

* Fix find_address_signatures_for_slot methods

* Fix get_block_signatures methods

* Fix get_confirmed_signatures_for_address2

* Remove unused method

* Fix test_all_empty_or_min moar (builds except tests)

* Fix tests (all build)

* Fix test_get_confirmed_signatures_for_address

* Fix test_lowest_cleanup_slot_and_special_cfs moar

* Unignore tests (builds except tests)

* Fix test_purge_transaction_status_exact

* Fix test_purge_front_of_ledger

* Fix test_purge_special_columns_compaction_filter (all build)

* Move some test-harness stuff around

* Add test cases for purge_special_columns_with_old_data

* Add test_read_transaction_status_with_old_data

* Add test_get_transaction_status_with_old_data

* Review comments

* Move rev of block-signatures into helper

* Improve deprecated_key impls

* iter_filtered -> iter_current_index_filtered

* Add comment to explain why use the smallest (index, Signature) to seed the iterator

* Impl ColumnIndexDeprecation for TransactionMemos (doesn't build)

* Update TransactionMemos put

* Add LedgerColumn::get_raw

* Fix read_transaction_memos

* Add TransactionMemos to purge_special_columns_exact

* Add TransactionMemos to compaction filter

* Take find_address_signatures out of service

* Remove faulty delete_new_column_key logic

* Simplify comments
2023-10-10 10:40:36 -06:00
Ryo Onodera 1704789247
Define tick related helper test methods (#33537)
* Define tick related helper methods

* dcou VoteSimulator

* blacklist ledger-tool for dcou

* fix dcou ci...

* github
2023-10-10 09:23:18 +09:00
Tyera f075867ceb
Blockstore::get_sigs_for_addr2: ensure lowest_slot >= first_available_block (#33556)
* Set empty lowest_slot to first_available_block and remove check in loop

* Ensure get_transaction_status on_with_counter returns slots >= first_available_block

* Actually cleanup ledger
2023-10-06 15:12:08 -06:00
Tyera 6f1922b4fd
Add early return to Blockstore::find_address_signatures methods (#33545)
Add early return to find_address_signatures methods
2023-10-05 19:57:35 +00:00
steviez 666ce9b3be
Fix blockstore-purge delete_files_in_range_us metric (#33512)
This field was being filled with the wrong value
2023-10-05 13:34:04 -05:00
steviez fac0c3c0fc
Make Blockstore::purge_special_columns_exact() bail if columns empty (#33534)
The special columns, TransactionStatus and AddressSignatures, are only
populated if --enable-rpc-transaction-history is passed. Cleaning these
columns for a range of slots is very expensive, as the block for each
slot must be read, deserialized, and then parsed to extract all of the
transaction signatures and address pubkeys.

This change adds a simple check to see if there are any values at all in
the special columns. If there are not, then the whole process described
above can be skipped for nodes that are not storing the special columns.
2023-10-05 13:15:24 -05:00
steviez 6b96a2259f
Remove unused code in Blockstore underlying impl (#33538)
* Remove LedgerColumn::delete_slot() method
* Remove primary_index() function from Trait column
2023-10-05 13:14:09 -05:00
steviez 402e9a5fff
Use copy_from_slice() over clone_from_slice() for u8 slice copies (#33536)
clone_from_slice() would hypothetically visit each item in the slice and
clone it whereas copy_from_slice() can memcpy the whole slice in one go.

Technically, Rust does the right thing for us by making
clone_from_slice() defer to copy_from_slice() for types that implement
Copy trait. However, we should still use the more efficient method
directly to show intent.
2023-10-05 13:13:09 -05:00
kirill lykov a25bb2e303
Add error messages for BlockstoreError (#33427)
* Add error messages for BlockstoreError

* display underlying errors

* address PR comments: remove unnecessary error from msg

Co-authored-by: steviez <stevecz@umich.edu>

* fix typo

Co-authored-by: steviez <stevecz@umich.edu>

---------

Co-authored-by: steviez <stevecz@umich.edu>
2023-10-04 18:17:42 +02:00
Andrew Fitzgerald 5a95e5676e
Manually add lookup table addresses instead of sanitizing (#33273) 2023-10-04 08:04:43 -07:00
Tyera 144e6d6eec
Blockstore special columns: minimize deletes in PurgeType::Exact (#33498)
* Adjust test_purge_transaction_status_exact to test slots that cross primary indexes

* Minimize deletes by checking the primary-index range

* Fix test_purge_special_columns_compaction_filter
2023-10-04 00:58:30 +00:00
steviez 9761e6f251
Remove dummy entries in Blockstore special columns (#33511)
These entries were found to improve compaction performance when
LedgerCleanupService was performing direct compactions on each primary
index. Cleaning by primary index has been deprecated for a while, and
as such, these dummy entries are no longer needed and can be removed.
2023-10-03 15:53:55 -05:00
Tyera 7adab97ffd
Add test for compaction filter purge (#33494)
* Add Database::compact_range_cf method

* Add test of CompactionFilter purge
2023-10-02 20:22:51 -06:00
Andrew Fitzgerald 660e41a8e1
Remove entry shuffling (#33378) 2023-10-02 09:03:12 -07:00
steviez 4866789b67
Fix off-by-one bug in Blockstore::purge_exact() (#33463) 2023-09-30 00:14:40 +02:00
Jon Cinque de38b05ad1
spl: Bump token-2022 and friends (#33453)
* token: Update to 4.0.0

* token-2022: Bump and support new account and instruction types

* Update token-2022 in fetch_spl / program-test

* Fixup downstream uses

* Mint and destination were flipped in 0.9.0

* Don't use `convert_pubkey`

* Bump spl dependencies to versions which avoid recompilations
2023-09-29 19:12:06 +02:00
steviez 3428333127
Switch confirmed_unrooted_slots from Vec<_> to HashSet<_> (#33311)
The container is only used to check for inclusion of slots with
the .contains() method. This method is O(n) on a Vec<_> but O(1) on a
HashSet<_>.
2023-09-22 07:15:47 +02:00
steviez 357eabd5f3
Move LedgerColumn delete() implementation to less restrictive traits (#33304) 2023-09-21 02:06:00 -04: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
Pankaj Garg f50342a790
Split vote related code from runtime to its own crate (#32882)
* Move vote related code to its own crate

* Update imports in code and tests

* update programs/sbf/Cargo.lock

* fix check errors

* update abi_digest

* rebase fixes

* fixes after rebase
2023-09-19 10:46:37 -07:00
behzad nouri 528a03f32a
removes outdated matches crate from dependencies (#33172)
removes outdated matches crate from the dependencies

std::matches has been stable since rust 1.42.0.
Other use-cases are covered by assert_matches crate.
2023-09-07 12:52:57 +00: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
behzad nouri 1431275328
removes outdated check for merkle shreds (#33088) 2023-08-31 20:01:54 +00:00
Ashwin Sekar 6d2dae6ab0
send duplicate shred proofs for conflicting shred scenarios (#32965)
* send duplicate shred proofs for conflicting shred scenarios

The scenarios are multiple last_shred_in_slot shreds and
coding shreds with conflicting erasure metas.

* Pr feedback: deprecate shred_index for gossip duplicate shred proofs

* Pr feedback

* Remove extraneous dead code
2023-08-31 12:08:10 -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
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
Brooks 9a6cf3f528
Renames SnapshotRequestType to SnapshotRequestKind (#32907) 2023-08-21 07:12:20 -04:00
behzad nouri 7bd7410592
uses typed Pubkey instead of opaque [u8; 32] (#32842) 2023-08-18 23:28:08 +00:00
steviez a4c8cc3ce0
Remove improper uses of &Arc<Bank> (#32802)
In most cases, either a &Bank or an Arc<Bank> is more proper.
- &Bank is used if the function only needs a momentary reference
- Arc<Bank> is used if the function needs its' own copy

This PR leaves several instances of &Arc<Bank> around; these instances
are situations where a clone may only happen conditionally.
2023-08-18 16:46:34 -05:00
Pankaj Garg f4287d70bb
Move accounts-db code to its own crate (#32766) 2023-08-09 13:03:36 -07:00
carllin d5faa6e8aa
Local Cluster Duplicate Switch Test (#32614)
* Add test for broken behavior in same batch

* tests

* redo test

* Important fixes to not immediately duplicate confirm by adding extra node

* Fixup merge

* PR comments

* Redo stakes

* clippy

* fixes

* Resolve conflicts

* add thread logging

* Fixup merge

* Fixup bugs

* Revert "add thread logging"

This reverts commit 9dc22401054b8f91f2b2aa3033e482996913febb.

* Hide scope

* Fixes

* Cleanup test_faulty_node

* More fixes

* Fixes

* Error logging

* Fix duplicate confirmed

* done

* PR comments

* Revert "Error logging"

This reverts commit 18953c36a5e865ecdd38bbf49b8d0502448087d2.

* PR comments

* nit
2023-08-08 19:29:39 -04:00
steviez 028f10d3d1
ledger-tool: Add flag to ignore open file descriptor limit error (#32624)
The current desired open file descriptor limit is 1,000,000. This is
quite a large number, and not needed for every command. Namely, commands
that do not unpack a snapshot and create an AccountsDB will likely not
use this many files.

There is already an option in BlockstoreOptions to ignore errors if the
desired value cannot be set; this PR just bubbles that option up to a
CLI flag in ledger-tool.
2023-07-27 11:50:45 -05:00
steviez cd39a6afd3
Make use of Blockstore's LedgerColumn objects (#32506)
* Move functions that take a &Database under impl Blockstore {...}
* Replace &Database with &self in those functions and update callers
* Use LedgerColumn's from Blockstore instead of re-fetching
* Add missing roots LedgerColumn and have it report metrics like others
* Remove several redundant comments
2023-07-25 10:25:12 -05:00
Pankaj Garg aba637d5d9
Split snapshot_utils.rs into snapshot_bank_utils.rs (#32612) 2023-07-24 16:31:03 -07:00
dependabot[bot] c2d605b884
Bump bitflags from 1.3.2 to 2.3.3 (#32438)
* Bump bitflags from 1.3.2 to 2.3.3

Bumps [bitflags](https://github.com/bitflags/bitflags) from 1.3.2 to 2.3.3.
- [Release notes](https://github.com/bitflags/bitflags/releases)
- [Changelog](https://github.com/bitflags/bitflags/blob/main/CHANGELOG.md)
- [Commits](https://github.com/bitflags/bitflags/compare/1.3.2...2.3.3)

---
updated-dependencies:
- dependency-name: bitflags
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* updates programs/sbf/Cargo.lock

* derives necessary traits

* replaces from_bits_unchecked with from_bits_retain

* patches test

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: behzad nouri <behzadnouri@gmail.com>
2023-07-24 12:56:55 +00:00
steviez d73fa1b590
Re-enable periodic compaction on several columns (#32548)
Periodic compaction was previously disabled on all columns in #27571 in
favor of the delete_file_in_range() approach that #26651 introduced.
However, several columns still rely on periodic compaction to reclaim
storage. Namely, the TransactionStatus and AddressSignatures columns, as
these columns contain a slot in their key, but as a non-primary index.

The result of periodic compaction not running on these columns is that
no storage space is being reclaimed from columns. This is obviously bad
and would lead to a node eventually running of storage space and
crashing.

This PR reintroduces periodic compaction, but only for the columns that
need it.
2023-07-20 16:34:42 -05:00
behzad nouri 7f2f0136bd
enables merkle shreds for devnet and development clusters (#32533) 2023-07-20 12:47:28 +00:00
carllin b6927db6a8
Detect duplicates in the same insert batch (#32528) 2023-07-19 21:17:59 -04:00
steviez c2ae30eb4d
Simplify signature for Blockstore::is_shred_duplicate() (#32537)
The existing signature unpacked elements from a Shred and took an owned
Vec<u8>, forcing a .clone() from the caller. The Shred can be passed in
directly to simplify argument list and avoid the clone.
2023-07-19 13:54:29 -05:00
steviez 106c5569d3
Use Slot type instead of u64 for clarity (#32525) 2023-07-18 15:42:35 -05:00