Commit Graph

25172 Commits

Author SHA1 Message Date
Joe C 3627038541
Runtime: Core BPF Migration: Struct for loading and checking source BPF program accounts (#332)
* runtime: core_bpf_migration: add source_bpf_upgradeable config

* runtime: core_bpf_migration: add source_bpf_upgradeable config tests

* renamings

* bincode error

* drop `total_size`
2024-03-26 07:05:10 -05:00
samkim-crypto a3bc406b55
[zk-token-sdk] Remove `std::thread` from wasm target (#379) 2024-03-26 19:54:06 +09:00
kirill lykov 1261f1f900
Add analysis for bench-tps transactions (#92)
* save progress

* rename threads handler

* added writer for txs

* after extracting structure to handle tx confirmations

* extract LogWriter

* Replace pair TimestampedTransaction with struct

* add compute_unit_price to TimestampedTransaction

* add cu_price to LogWriter

* add block time to the logs

* Fix warnings

* add comments and restructure code

* some small improvements

* Renamed conformation_processing.rs to log_transaction_service.rs

* address numerous PR comments

* split LogWriter into two structs

* simplify code of LogWriters

* extract process_blocks

* specify commitment in LogTransactionService

* break thread loop if receiver happens to be dropped

* update start_slot when processing blocks

* address pr comments

* fix clippy error

* minor changes

* fix ms problem

* fix bug with time in clear transaction map
2024-03-26 11:47:24 +01:00
behzad nouri 30eecd62b1
implements weighted shuffle using N-ary tree (#259)
This is port of firedancer's implementation of weighted shuffle:
https://github.com/firedancer-io/firedancer/blob/3401bfc26/src/ballet/wsample/fd_wsample.c

https://github.com/anza-xyz/agave/pull/185
implemented weighted shuffle using binary tree. Though asymptotically a
binary tree has better performance, compared to a Fenwick tree, it has
less cache locality resulting in smaller improvements and in particular
slower WeightedShuffle::new.

In order to improve cache locality and reduce the overheads of
traversing the tree, this commit instead uses a generalized N-ary tree
with fanout of 16, showing significant improvements in both
WeightedShuffle::new and WeightedShuffle::shuffle.

With 4000 weights:

N-ary tree (fanout 16):

    test bench_weighted_shuffle_new     ... bench:      36,244 ns/iter (+/- 243)
    test bench_weighted_shuffle_shuffle ... bench:     149,082 ns/iter (+/- 1,474)

Binary tree:

    test bench_weighted_shuffle_new     ... bench:      58,514 ns/iter (+/- 229)
    test bench_weighted_shuffle_shuffle ... bench:     269,961 ns/iter (+/- 16,446)

Fenwick tree:

    test bench_weighted_shuffle_new     ... bench:      39,413 ns/iter (+/- 179)
    test bench_weighted_shuffle_shuffle ... bench:     364,771 ns/iter (+/- 2,078)

The improvements become even more significant as there are more items to
shuffle. With 20_000 weights:

N-ary tree (fanout 16):

    test bench_weighted_shuffle_new     ... bench:     200,659 ns/iter (+/- 4,395)
    test bench_weighted_shuffle_shuffle ... bench:     941,928 ns/iter (+/- 26,492)

Binary tree:

    test bench_weighted_shuffle_new     ... bench:     881,114 ns/iter (+/- 12,343)
    test bench_weighted_shuffle_shuffle ... bench:   1,822,257 ns/iter (+/- 12,772)

Fenwick tree:

    test bench_weighted_shuffle_new     ... bench:     276,936 ns/iter (+/- 14,692)
    test bench_weighted_shuffle_shuffle ... bench:   2,644,713 ns/iter (+/- 49,252)
2024-03-26 05:21:54 +00:00
carllin b01d7923fc
Add local cluster utitlity functions (#355) 2024-03-26 00:34:15 -04:00
samkim-crypto f6a3608981
[clap-v3-utils] Add `try_get_word_count` (#411) 2024-03-26 13:25:57 +09:00
samkim-crypto c867522de8
[clap-v3-utils] Make `SignerSource::parse` public (#410)
make `SignerSource::parse` public
2024-03-26 07:42:31 +09:00
Yueh-Hsuan Chiang c7dba30f4f
[TieredStorage] Disable accounts-file type check before enabling tiered-storage (#418)
#### Problem
As #72 introduced AccountsFile::TieredStorage, it also performs
file-type check when opening an accounts-file to determine whether
it is a tiered-storage or an append-vec.  But before tiered-storage is
enabled, this opening check is unnecessary.

#### Summary of Changes
Remove the accounts-file type check code and simply assume everything
is append-vec on AccountsFile::new_from_file().
2024-03-25 12:08:48 -07:00
Lucas Steuernagel b884ea8011
Add examples of failing transactions to SVM integration tests (#417)
Add examples of failing transactions
2024-03-25 16:02:58 -03:00
Yueh-Hsuan Chiang a916edb7a2
[TieredStorage] Add AccountsFile::TieredStorage (#72)
#### Problem
AccountsFile currently doesn't have an implementation for TieredStorage.
To enable AccountsDB tests for the TieredStorage, we need AccountsFile
to support TieredStorage.

#### Summary of Changes
This PR implements a AccountsFile::TieredStorage, a thin wrapper between
AccountsFile and TieredStorage.
2024-03-24 16:41:36 -07:00
Yueh-Hsuan Chiang 602471257e
[TieredStorage] Add capacity() API and limit file size to 16GB (#401)
#### Problem
The TieredStorage has not yet implemented the AccountsFile::capacity()
API.

#### Summary of Changes
Implement capacity() API for TieredStorage and limit file size to 16GB,
same as the append-vec file.
2024-03-23 22:14:19 -07:00
behzad nouri b6d2237403
implements weighted shuffle using binary tree (#185)
This is partial port of firedancer's implementation of weighted shuffle:
https://github.com/firedancer-io/firedancer/blob/3401bfc26/src/ballet/wsample/fd_wsample.c

Though Fenwick trees use less space, inverse queries require an
additional O(log n) factor for binary search resulting an overall
O(n log n log n) performance for weighted shuffle.

This commit instead uses a binary tree where each node contains the sum
of all weights in its left sub-tree. The weights themselves are
implicitly stored at the leaves. Inverse queries and updates to the tree
all can be done O(log n) resulting an overall O(n log n) weighted
shuffle implementation.

Based on benchmarks, this results in 24% improvement in
WeightedShuffle::shuffle:

Fenwick tree:
    test bench_weighted_shuffle_new     ... bench:      36,686 ns/iter (+/- 191)
    test bench_weighted_shuffle_shuffle ... bench:     342,625 ns/iter (+/- 4,067)

Binary tree:
    test bench_weighted_shuffle_new     ... bench:      59,131 ns/iter (+/- 362)
    test bench_weighted_shuffle_shuffle ... bench:     260,194 ns/iter (+/- 11,195)

Though WeightedShuffle::new is now slower, it generally can be cached
and reused as in Turbine:
https://github.com/anza-xyz/agave/blob/b3fd87fe8/turbine/src/cluster_nodes.rs#L68

Additionally the new code has better asymptotic performance. For
example with 20_000 weights WeightedShuffle::shuffle is 31% faster:

Fenwick tree:
    test bench_weighted_shuffle_new     ... bench:     255,071 ns/iter (+/- 9,591)
    test bench_weighted_shuffle_shuffle ... bench:   2,466,058 ns/iter (+/- 9,873)

Binary tree:
    test bench_weighted_shuffle_new     ... bench:     830,727 ns/iter (+/- 10,210)
    test bench_weighted_shuffle_shuffle ... bench:   1,696,160 ns/iter (+/- 75,271)
2024-03-23 13:53:46 +00:00
Joe C bfdfc6cef2
frozen-abi-macro: use `log` from `solana_frozen_abi` (#153)
* frozen-abi-macro: use `log` from `solana_frozen_abi`

* use private module approach
2024-03-23 07:38:57 -05:00
Pankaj Garg 5cfb6e860d
SVM: Move sysvar_cache related functions and tests to SVM (#402) 2024-03-22 19:45:34 -07:00
Tyera 6e6acce798
Clarify TargetProgramBuiltin code docs (#403)
* Update comments

* Nitty variable name update
2024-03-22 23:44:38 +00:00
Lucas Steuernagel bcaf7a8f6c
Sysvar example (#399) 2024-03-22 20:26:46 -03:00
Yueh-Hsuan Chiang e9cc9f8379
[TieredStorage] Refactor file_size() code path (#400)
#### Problem
TieredStorage::file_size() essentially supports AccountsFile::len(),
but its API is inconsistent with AccountsFile's.

#### Summary of Changes
Refactor TieredStorage::file_size() to ::len() and share the same API
as AccountsFile's.

#### Test Plan
Build
Existing unit-tests.
2024-03-22 14:21:24 -07:00
Pankaj Garg 9a447ab6bd
SVM: bank to use program cache from transaction_processor (#397) 2024-03-22 14:05:20 -07:00
Yueh-Hsuan Chiang f1a82cb666
[TieredStorage] Use mmap.len() in TieredStorage::file_size() for HotStorage (#381)
#### Problem
The current implementation of TieredStorage::file_size() requires
a sys-call to provide the file size.

#### Summary of Changes
Add len() API to TieredStorageReader, and have HotStorageReader()
implement the API using Mmap::len().

#### Test Plan
Update existing unit-test to also verify HotStorageReader::len().
2024-03-22 11:56:30 -07:00
Lucas Steuernagel fe16e84806
Include simple transfer example in SVM (#388) 2024-03-22 15:45:59 -03:00
Yueh-Hsuan Chiang 977b1b836f
Rename AppendVecId to AccountsFileId (#383)
#### Problem
The current AppendVecId actually refers to an accounts file id.

#### Summary of Changes
Rename AppendVecId to AccountsFileId.

#### Test Plan
Build
2024-03-22 11:25:30 -07:00
Brooks 24fe473b46
clippy: Automated fixes for Rust 1.77.0 (#390) 2024-03-22 13:48:46 -04:00
Brooks 5cacca99b4
Fixes help text formatting (#385) 2024-03-22 12:56:54 -04:00
Justin Starry 2ee606da4f
Add `--with-compute-unit-price` to cli program deploy commands (#364)
* add set compute units arg for program deploy

* update master changes

* remove duplicates

* fixes and tests

* remove extra lines

* feedback

* Use simulation to determine compute units consumed

* feedback

---------

Co-authored-by: NagaprasadVr <nagaprasadvr246@gmail.com>
2024-03-22 16:48:52 +00:00
Joe C 62d49f123a
Runtime: Core BPF Migration: Struct for loading and checking builtin program accounts (#331)
* runtime: core_bpf_migration: add builtin config

* runtime: core_bpf_migration: add builtin config tests

* some renaming feedback
2024-03-22 11:25:10 -05:00
Joe C f799c9ff67
Runtime: Expose builtin program IDs to crate (#318)
* runtime: bank: rename `builtin_programs` to `builtin_program_ids`

* runtime: snapshot minimizer: use builtin IDs from bank
2024-03-22 11:24:49 -05:00
Andrew Fitzgerald 84639441c0
Support --block-production-method in banking-bench (#269) 2024-03-22 09:12:21 -07:00
Pankaj Garg 91b1ee3df6
Fix: deploy program on last slot of epoch during environment change (#101)
* Fix: deploy program on last slot of epoch during environment change

* solana-runtime: deploy at last epoch slot test

* disable deployment of sol_alloc_free

* Move tx-batch-constructor to its own function

* use new_from_cache

---------

Co-authored-by: Alessandro Decina <alessandro.d@gmail.com>
2024-03-22 07:43:28 -07:00
Jon C 36c66f5111
client: Timeout resends during `send_and_confirm_in_parallel` (#358)
* client: Timeout resends during `send_and_confirm_in_parallel`

* Clarify constant
2024-03-22 12:10:00 +01:00
Alexander Meißner 8f830c418c
Rekey - alt_bn128 and poseidon_syscall (#319)
Adds simplify_alt_bn128_syscall_error_codes.
2024-03-22 07:58:47 +01:00
blake 0906b8996c
Health check slot distance (#335)
Changed validator health check slot distance to 128 to be consistent
2024-03-22 00:11:36 -05:00
Brooks cbd0369da1
Uses AppendVecId in AccountsFIle::file_name() (#372) 2024-03-21 21:27:03 -04:00
samkim-crypto c7cdf238f0
[clap-v3-utils] Remove deprecated functions (#313)
* add `deprecated` feature to produce warnings on use of deprecated functions

* replace `multiple_occurrences` with arg actions

* replace `possible_values` with `PossibleValueParser`

* deprecated `value_of` and `values_of`

* deprecate `unix_timestamp_from_rfc3339_datetime`

* deprecate `cluster_type_of`

* deprecate `commitment_of`

* deprecate `keypair_of`, `keypairs_of`, `pubkey_of`, and `pubkeys_of` functions

* replace deprecated functions from `try_keypair_of`, `try_keypairs_of`, `try_pubkey_of`, and `try_pubkeys_of`

* deprecate `pubkeys_sigs_of`

* allow deprecated on tests

* remove `deprecation` feature from clap-v3-utils

* re-export `pubkeys_sigs_of`

* add helper `extract_keypair` to dedupe `try_keypair_of` and `try_keypairs_of`

* remove unwraps and expects

* bump deprecation version
2024-03-22 07:52:42 +09:00
carllin e963f87da9
Evict oldest vote on vote refresh after restart (#327) 2024-03-21 17:54:17 -04:00
Andrew Fitzgerald 5f1693224e
Discard packets statically known to fail (#370)
* Discard packets statically known to fail

* add test
2024-03-21 20:47:16 +00:00
Brooks 8b66a670b7
Removes AccountsFile::is_recyclable() (#359) 2024-03-21 15:09:26 -04:00
Lucas Steuernagel 4d838d5af9
Add `hello-solana` example source files to SVM folder (#361) 2024-03-21 15:12:32 -03:00
Tyera dff99d0740
Cli stake-split: adjust transfer amount if recipient has lamports (#266)
* Remove incorrect check

* Move to closure

* Use match statement instead

* Adjust rent_exempt_reserve by existing balance

* Only transfer lamports if rent_exempt_reserve needs are greater than 0

* Rename variable for clarity

* Add minimum-delegation check

* Bump test split amount to meet arbitrary mock minimum-delegation amount
2024-03-21 11:03:55 -06:00
Greg Cusack 792d7454d9
switch to `solana-tpu-client` from `solana_client::tpu_client` for `bench-tps`, `dos/`, `LocalCluster`, `gossip/` (#310)
* switch over to solana-tpu-client for bench-tps, dos, gossip, local-cluster

* put TpuClientWrapper back in solana_client
2024-03-21 09:25:54 -07:00
Jon C b2f4fb306e
client: Start resending sooner during `send_and_confirm_transactions_in_parallel` (#348)
client: Confirm sooner during send_and_confirm_in_parallel
2024-03-21 14:35:09 +01:00
Tao Zhu 1e08e90498
Add functions to collect executed transactions fee in details; (#178)
* Add functions to collect executed transactions fee in details;

* remove unnecessary derive attributes

* change function name from add to accumulate; remove collector_fee_details from PartialEq

* add AbiExample

* add test

* share function to withdraw errored transaction

* more tests
2024-03-21 04:33:35 +00:00
Alessandro Decina 981881544c
runtime: do fewer syscalls in remap_append_vec_file (#336)
* runtime: do fewer syscalls in remap_append_vec_file

Use renameat2(src, dest, NOREPLACE) as an atomic version of if
statx(dest).is_err() { rename(src, dest) }.

We have high inode contention during storage rebuild and this saves 1
fs syscall for each appendvec.

* Address review feedback
2024-03-21 14:28:23 +11:00
Wen 11aa06d24f
wen-restart: Find heaviest fork (#183)
* Pass the final result of LastVotedForkSlots aggregation to next
stage and find the heaviest fork we will Gossip to others.

* Change comments.

* Small fixes to address PR comments.

* Move correctness proof to SIMD.

* Fix a broken merge.

* Use blockstore to check parent slot of any block in FindHeaviestFork

* Change error message.

* Add special message when first slot in the list doesn't link to root.
2024-03-20 19:38:46 -07:00
Joe C f194f70e68
Runtime: Refactor builtins module (#304)
* runtime: builtins: move to new bank submodule

* runtime: builtins: change `feature_id` to `enable_feature_id`

* runtime: builtins: add stateless builtins
2024-03-20 20:46:38 -05:00
Dmitri Makarov 54575feb42
SVM: add a missing doc comment (#347) 2024-03-20 20:03:20 -04:00
Alessandro Decina ade90354a1
runtime: use str::split instead of regex to parse appendvec filenames (#323) 2024-03-21 09:14:16 +11:00
steviez 4a67cd495b
Allow configuration of replay thread pools from CLI (#236)
Bubble up the constants to the CLI that control the sizes of the
following two thread pools:
- The thread pool used to replay multiple forks in parallel
- The thread pool used to execute transactions in parallel
2024-03-20 15:07:04 -05:00
Dmitri Makarov 09ae5872b3
Rename LoadedPrograms to ProgramCache for readability (#339) 2024-03-20 15:26:45 -04:00
Yueh-Hsuan Chiang 3038d47f1c
[TieredStorage] Store account address range (#172)
#### Problem
The TieredStorageFooter has the min_account_address and
max_account_address fields to describe the account address
range in its file.  But the current implementation hasn't updated
the fields yet.

#### Summary of Changes
This PR enables the TieredStorage to persist address range
information into its footer via min_account_address and
max_account_address.

#### Test Plan
Updated tiered-storage test to verify persisted account address range.
2024-03-20 12:17:12 -07:00
Yueh-Hsuan Chiang 0e932c7308
[TieredStorage] Refactor TieredStorage::new_readonly() code path (#195)
#### Problem
The TieredStorage::new_readonly() function currently has the following
problems:

* It opens the file without checking the magic number before checking and loading the footer.
* It opens the file twice: first to load the footer, then open again by the reader.

#### Summary of Changes
This PR refactors TieredStorage::new_readonly() so that it first performs all
checks inside the constructor of TieredReadableFile.  The TieredReadableFile
instance is then passed to the proper reader (currently HotStorageReader)
when all checks are passed.

#### Test Plan
* Added a new test to check MagicNumberMismatch.
* Existing tiered-storage tests
2024-03-20 10:39:25 -07:00