Commit Graph

4336 Commits

Author SHA1 Message Date
HaoranYi 37a36384f3
Test stake program execution restricted in reward period (#32404)
test stake program execution restricted in reward period

Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-07-07 10:24:49 -05:00
Illia Bobyr 282e043177
`cargo fmt` using 1.6.0-nightly (#32390)
Seems like rustfmt 1.6.0 can now format `let/else` statements.
1.5.2 we use in our `solana-nightly` does not mind the reformatting.

```
$ cargo +nightly fmt --version
rustfmt 1.6.0-nightly (f20afcc 2023-07-04)

$ cargo +nightly fmt
$ git add -u
$ git commit

$ ./cargo nightly fmt --version
+ exec cargo +nightly-2023-04-19 fmt --version
rustfmt 1.5.2-nightly (c609da5 2023-04-18)

$ ./cargo nightly fmt
$ git diff
[empty output]
```
2023-07-06 20:45:29 -07:00
HaoranYi 8273b103d2
Test rewards compuation and partitioned rewards distribution at the epoch boundary (#32349)
* Test rewards compuation and partitioned rewards distribution at the epoch boundary

* reviews

* match to if

* clippy

* peeling of bank1 from the loop

* collapse if_same

---------

Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-07-06 14:49:09 -05:00
Pankaj Garg 4674b0099f
Move CostModel and CostTracker to its own crate (#32354)
* Move CostModel and CostTracker to its own crate

* compile new crate and update imports

* update sbf Cargo.lock

* fix AbiExample

* fix cargo sort

* Fix AbiExample
2023-07-06 10:08:18 -07:00
Pankaj Garg b060f62004
Move transaction results data structures out of bank.rs (#32386)
* Move transaction results data structures out of bank.rs

* Fix CI check failures
2023-07-06 09:45:01 -07:00
Yueh-Hsuan Chiang fbb1dd5fe5
Replace AccountsFile::cloned_account by ReadableAccount::to_account_shared_data() (#32399)
#### Problem
Both AppendVec::cloned_account() and ReadableAccount::to_account_shard_data()
returns an AccountSharedData instance by cloning itself as pointed out under
a comment in PR #32380.

#### Summary of Changes
This PR removes AccountsFile::cloned_account() and replaces its call-sites by
ReadableAccount::to_account_shared_data().
2023-07-07 00:08:50 +08:00
Yueh-Hsuan Chiang f1836bb10f
[TieredAccountStorage] TieredReadableAccount (#32380)
#### Summary of Changes
This PR introduces TieredReadableAccount, a struct that takes a generic
TieredAccountMeta that implements ReadableAccount and support
StoredAccountMeta.

#### Test Plan
More tests will be added once more reader and writer functions for hot
accounts have been added.
2023-07-07 00:08:09 +08:00
Brooks d08ce116b3
Measures accounts hash calculation time (#32385) 2023-07-05 15:53:36 -04:00
Brooks f1f0f451b7
Adds cache_hash_data_us to HashStats (#32371) 2023-07-05 13:57:07 -04:00
Pankaj Garg 356a827087
Move NonceInfo, NonceFull and NoncePartial out of bank.rs (#32375)
* Move NonceInfo, NonceFull and NoncePartial out of bank.rs

* fix imports

* move test_nonce_info to nonce_info.rs
2023-07-05 10:44:54 -07:00
Brooks c80981070c
Adds mark_time and sort_time to HashStats total_time (#32370) 2023-07-05 12:26:31 -04:00
Brooks 52fe7eb1cf
Renames HashStats "sort" to "sort_us" (#32369) 2023-07-05 09:35:44 -04:00
Yueh-Hsuan Chiang 806d79a643
[TieredStorage] Improve TieredAccountMeta API's readability (#32338)
#### Problem
In TieredAccountMeta, it uses `data` and `account_data` to refer to
the data associated with the account, and this could be confusing.

#### Summary of Changes
This PR makes TieredAccountMeta only use `account_data` to refer
to the data associated with the account.
2023-07-01 01:55:13 +08:00
HaoranYi 9b405b21ff
Test `EpochRewards` sysvar creation, distribution, and burning. (#32339)
* Test `EpochRewards` sysvar creation, distribution, and burning.

* Update runtime/src/bank/tests.rs

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

---------

Co-authored-by: HaoranYi <haoran.yi@solana.com>
Co-authored-by: Brooks <brooks@prumo.org>
2023-06-30 10:46:31 -05:00
HaoranYi fccc1c75f3
test partitioned reward history update from rewards slice (#32334)
Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-06-30 09:44:20 -05:00
Yueh-Hsuan Chiang 2850432b57
[TieredStorage] Make data_size related APIs cleaner (#32317)
#### Problem
Function data_size_for_shared_block() is designed to provide
the data_size when its account shares its account block with
other accounts.  However, TieredAccountMeta already has another
function for returning data size.

#### Summary of Changes
This PR removes data_size_for_shared_block() from TieredAccountMeta.
Will follow-up with another PR that includes a better API.
2023-06-30 02:44:57 +08:00
Brooks d62f5ba37b
Removes unnecessary casts calling datapoint! (#32333) 2023-06-29 14:43:07 +00:00
HaoranYi 801bc2c814
Add test for partitioned epoch rewards store (#32319)
add tests for partitioned epoch rewards store

Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-06-29 08:57:03 -05:00
Ryo Onodera 5b6c3ba81b
Make prepare_simulation_batch() more usable (#32304)
* Make prepare_simulation_batch() more usable

* Rename

* Use `use`
2023-06-29 11:20:42 +09:00
Yueh-Hsuan Chiang 9c9db4a461
[TieredAccountStorage] getter functions for HotAccountMeta (#32296)
#### Summary of Changes
This PR implements HotAccountMeta's getter functions for accessing
optional fields (e.g. rent_epoch, account_hash, etc) and account data.

#### Test Plan
A new unit test is included in this PR.
2023-06-29 04:17:57 +08:00
HaoranYi 05ba9d58fb
Add test for partition out of range (#32312)
add test for partition out of range

Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-06-28 14:58:37 -05:00
Yueh-Hsuan Chiang 5e830d2692
[TieredAccountStorage] functions for obtaining optional fields offsets (#32311)
#### Summary of Changes
This PR adds several functions to AccountMetaOptionalFields
for obtaining the offset of each optional field.

#### Test Plan
New unit test cases are included in this PR.
2023-06-29 01:30:37 +08:00
Brooks 794f3849a4
Standardizes datapoints in AccountsBackgroundService's StatsManager (#32310) 2023-06-28 13:00:46 -04:00
Yueh-Hsuan Chiang 4cfdb374ae
[TieredStorage] byte_block::read_type (#32295)
#### Summary of Changes
This PR adds byte_block::read_type(), an util function that
reads the raw part of the input byte block at the specified offset
as type T.  This function will be later used by the hot storage.

#### Test Plan
Modified existing unit tests to use byte_block::read_type()
when the input byte block is properly aligned.
2023-06-28 12:33:29 +08:00
Brooks 9fb105c801
Cleanup impl for remove_tmp_snapshot_archives() (#32297) 2023-06-27 15:51:28 -04:00
Brooks 13aff74f82
Cleanup filesystem error handling in snapshot_utils (#32286) 2023-06-27 13:08:47 -04:00
Wen 6f72258e3e
Vote refresh fix when outside slothash (#29948)
* When there are too many pubkeys in one slot, kick the one with lowest
stake out.

* Cache last_root to reduce read locks we need.

* Use slots_in_epoch to limit number of slots in the map.

* Fix lint errors.

* Only cache stake and slots per epoch once per epoch.

* Revert "Only cache stake and slots per epoch once per epoch."

This reverts commit 8658aad0083456794b4c4403adaf9c74d1a71d09.

* Vote at the tip of current fork if last vote is outside SlotHash
of the tip and last vote expired.

* Add unittest when last vote is outside slothash, we should vote at the tip
of the current fork.

* Revert "Use slots_in_epoch to limit number of slots in the map."

This reverts commit 93574f57a48d2a70fbbc0f62fa8810d3b6bee0af.

* Revert "Cache last_root to reduce read locks we need."

This reverts commit bb114ec2b62cb9c0207328b19c415f6116be0f1c.

* Revert "When there are too many pubkeys in one slot, kick the one with lowest"

This reverts commit 711e29a6a025fd4f11fbc97dcbbe90e4832be04c.

* Move new vote generation when last vote is outside slothash into the
main path, this actually makes more sense since we don't select where
to vote in two different places, and all the vote generation logic
is seamlessly inherited.

* - Move vote refresh to be behind select vote and do not refresh vote if a new
  vote is selected.
- Check whether last vote is inside slothash inside select_vote_and_reset_forks
- rename slot_within_slothash to is_in_slothashes_history
- remove one unittest for now, more tests will be added in a separate CL

* Remove new test, it will be in another file.

* Add is_in_slot_hashes_history test in the new file.

* Add unittest for the case when last vote is outside slot hashes.

* Small improvements and more unittests.

* Fix bad merge.

* Update docs/src/terminology.md

Co-authored-by: mvines <mvines@gmail.com>

* Put SwitchForkDecision::FailedSwitchThreshold logic into separate function.

* Make linter happy.

---------

Co-authored-by: mvines <mvines@gmail.com>
2023-06-26 18:21:24 -07:00
Brooks 4547549a73
Uses fs_err instead of SnapshotError::IoWithSourceAndFile (#32267) 2023-06-26 17:10:21 -04:00
Yueh-Hsuan Chiang 1b2b825c1f
[TieredStorage] getter functions for TieredAccountMeta trait (#32276)
#### Summary of Changes
This PR adds getter functions to the TieredAccountMeta for accessing
optional fields and account data.

#### Test Plan
This PR only adds methods to a trait.  More tests will be included in the
follow-up PRs.
2023-06-27 03:01:06 +08:00
steviez 77b587aa4d
Add constant for disabled snapshot interval (#32236)
Slot::MAX was used to specify that a type of snapshots should not be
created; define a constant to be that value and reference the constant
to have a single point of edit.
2023-06-26 12:26:56 -05:00
Brooks 95fae285a4
Introduces fs_err to snapshot_utils (#32266) 2023-06-26 13:14:27 -04:00
Brooks 394fc9b8fc
Adds "archive" to log when loading snapshot archives (#32278) 2023-06-26 12:32:28 -04:00
Brooks 814ea7ae9f
Removes file permission twiddling in snapshot test (#32277) 2023-06-26 12:17:14 -04:00
Brooks 644cdaaa48
Adds comments in BankSnapshotInfo::new_from_dir() when selecting Pre or Post (#32261) 2023-06-26 11:53:25 -04:00
Brooks 4fb6bbf92e
Refactors datapoints and logs in bank_from_xxx fns (#32255) 2023-06-26 11:33:58 -04:00
Pankaj Garg 089fb464a9
Move message_processor to program-runtime (#32268) 2023-06-24 15:55:39 -07:00
Tyera 02eaaae513
Clean up credits_auto_rewind feature (#32211)
* Remove credits_auto_rewind feature logic from stake program

* Obey clean-up orders

* Clippy prefers this match

* Remove credits_auto_rewind feature helpers from Bank

* Comment nit for language, and shrink to fit on one line
2023-06-24 10:26:27 -06:00
Pankaj Garg 0b8af56924
Remove message_processor dependency on solana_runtime (#32256) 2023-06-24 07:55:32 -07:00
Yueh-Hsuan Chiang 9a620b4862
[TieredStorage] HotAccountMeta (2/N) (#32227)
#### Summary of Changes
This PR introduces HotAccountMeta, the storage and in-memory struct of
the metadata struct for a hot account.

#### Test Plan
Unit tests are included in this PR.
Tested in mnb w/ the prototype implementation of the tiered account storage (#30626)
2023-06-24 01:25:54 +08:00
Yueh-Hsuan Chiang d95e976a71
[TieredStorage] AccountMetaOptionalFields::size_from_flags() (#32242)
#### Summary of Changes
This PR adds AccountMetaOptionalFields::size_from_flags that takes
`&AccountMegaFlags` and returns the size of the AccountMetaOptionalFields
based on the input AccountMegaFlags.

This function is needed because the reader of the TieredAccountMeta
directly extract all the Some fields of AccountMetaOptionalFields
from its account block without constructing the AccountMetaOptionalFields
instance.

#### Test plan
Improve existing unit tests that further verify the correctness of the function.
2023-06-23 01:42:02 +08:00
Yueh-Hsuan Chiang 1c618f2479
[TieredStorage] TieredAccountMeta (1/N) (#32220)
#### Summary of Changes
This PR introduces TieredAccountMeta, a trait that allows different implementations
of the account meta for different tiers of the accounts storage.

This PR includes the mutator and getter methods for the common TieredAccountMeta
fields.  Functions that also work with the account data block will be in separate PRs.
2023-06-23 01:40:43 +08:00
Ryo Onodera f62d231886
Make `ci/_` to print to stderr instead of stdout (#32238)
* make _ print to stderr instead...

* Trigger normal build procedure
2023-06-22 15:46:22 +09:00
Brooks ba05cbf4cc
Sets default snapshot archive format to zstd (#32205) 2023-06-21 15:15:53 -04:00
steviez 20a7cdd43d
Restrict access to Bank's HardForks (#32180)
* Restrict access to Bank's HardForks

Callers could previously obtain a a lock to read/write HardForks from
any Bank. This would allow any caller to modify, and creates the
opportunity for inconsistent handling of what is considered a valid hard
fork (ie too old).

This PR adds a function to Bank so consistent sanity checks can be
applied; the caller will already have a Bank as that is where they would
have obtained the HardForks from in the first place. Additionally,
change the getter to return a copy of HardForks (simple Vec).

* Allow hard fork at bank slot if bank is not yet frozen
2023-06-20 23:44:43 -05:00
HaoranYi 203544293b
Add epoch_rewards to sysvar cache (#32155)
add epoch_rewards to sysvar cache

Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-06-20 15:01:34 -05:00
HaoranYi 2e9aeff8dd
Enable partitioned epoch reward by feature id (#32174)
enable partitioned epoch reward feature by feature id
update stake rewards tests with partitioned epoch rewards feature enable

Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-06-20 12:12:50 -05:00
Yueh-Hsuan Chiang c56d0bc6a6
[TieredStorage] Make AccountMetaFlags::new_from pub (#32194)
#### Summary of Changes
The newly introduced AccountMetaFlags::new_from must be pub
in order to make the tiered storage writer able to use it.
2023-06-21 00:00:59 +08:00
galactus 2ceabd9368
Simd 47 syscall sysvar last restart slot (#31957)
* add sysvar and logic for last restart slot

* cleanup

* add test for getting last restart slot from account

* format code

* add some basic rustdoc

* copy+paste error

* feature flag for last_restart_slot

* add to sysvars.md

* updated wording in sysvars.md

* rename sol_get_last_restart_slot_sysvar > sol_get_last_restart_slot

* create sbf C header for sol_get_last_restart_slot

* cleanup imports

* reverted hardened_unpack workaround

* cleanup imports

* cleanup logs + blank lines

* Implementing ui changes for last restart slot, nit

* Some more nit change and implementing the UI for sysvar

* fixing the CI

* Minor clippy fix

* format changes

* changes suggested by mvines and lichtso

* increase timeout in local_cluster test

* fix code format

* use keypair for feature flag from mvines

* delete test.json file

* Revert "increase timeout in local_cluster test"

This reverts commit a67465ae22.

* last restart slot should be always less than or equal to current slot

* fixing bug

* changes after  steviez comments

* format issue fixed

* fixing the comment on premature application of future hardfork

* nit change in test

Co-authored-by: steviez <steven@solana.com>

* reverting sysvar_cache.rs because change was not necessary

---------

Co-authored-by: steve-gg <grooviegermanikus@gmail.com>
Co-authored-by: steviez <steven@solana.com>
2023-06-16 20:14:02 +00:00
Jeff Washington (jwash) 174ceba82b
rename to stake_rewards_by_partition for clarity (#32165) 2023-06-16 19:28:53 +00:00
HaoranYi 39d9f8974d
Revert "add test for is_partitioned_rewards_feature_enabled (#32158)" (#32176)
This reverts commit d06b099ecb.

Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-06-16 11:56:05 -05:00
HaoranYi d06b099ecb
add test for is_partitioned_rewards_feature_enabled (#32158)
* add set_partitioned_rewards_enabled_for_test fn

* reveiws

---------

Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-06-16 11:07:07 -05:00
HaoranYi af7b7f1436
Refactor reward block calculation fn (#32167)
refactor reward block calculation fn

Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-06-16 08:40:23 -05:00
Brooks 47ff3cecc9
Enables creating snapshots after booting from local state (#32137) 2023-06-15 22:54:32 -04:00
Jeff Washington (jwash) b1b7ae5e09
cleanup math in distribute_partitioned_epoch_rewards (#32164) 2023-06-15 16:17:38 -07:00
Jeff Washington (jwash) b4265217e6
update begin_partitioned_rewards to include sysvar (#32151)
* update begin_partitioned_rewards to include sysvar

* cleanup
2023-06-15 14:00:24 -07:00
Jeff Washington (jwash) d79b565c72
connect `begin_partitioned_rewards` to bank (#32152) 2023-06-15 11:51:10 -07:00
Jeff Washington (jwash) e7a676dc01
add distribute_partitioned_epoch_rewards (#32124)
* add distribute_partitioned_epoch_rewards

* reviews

* reanme

---------

Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-06-15 11:32:44 -05:00
Jeff Washington (jwash) 988bff93c8
deactivate_epoch_rewards_status burns sysvar (#32143)
* deactivate_epoch_reward_status burns sysvar

* warn to info

---------

Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-06-15 10:36:50 -05:00
Jeff Washington (jwash) 00b5c40122
add partitioned rewards sysvar fns (#32128) 2023-06-14 16:08:15 -07:00
Jeff Washington (jwash) 60e36afd42
add begin_partitioned_rewards (#32116)
* add begin_partitioned_rewards

* pr feedback

* Apply suggestions from code review

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

---------

Co-authored-by: HaoranYi <haoran.yi@gmail.com>
Co-authored-by: Brooks <brooks@prumo.org>
2023-06-14 14:24:49 -07:00
Jeff Washington (jwash) 088ac5ec01
add is_partitioned_rewards_code_enabled (#32123)
* add partitioned_rewards_code_enabled

* renames
2023-06-14 14:36:53 -05:00
Jeff Washington (jwash) f487dfbc77
add distribute_epoch_rewards_in_partition (#32125) 2023-06-14 11:03:17 -07:00
Jeff Washington (jwash) a1ce3cbaa3
partitioned rewards fn for tests: force_reward_interval_end_for_tests (#32127)
partitioned rewards fn for tests
2023-06-14 10:59:48 -07:00
Jeff Washington (jwash) 4eb7db8737
in testing, hash_internal_state ignores epoch_rewards_sysvar (#32122) 2023-06-14 10:57:29 -07:00
Jeff Washington (jwash) 9cf10b7aae
optionally compare with partitioned rewards (#32126) 2023-06-14 10:55:09 -07:00
Jeff Washington (jwash) c01250fc58
add calculate_rewards_and_distribute_vote_rewards (#32109)
* add calculate_rewards_and_distribute_vote_rewards

* warn -> info
2023-06-14 08:38:25 -07:00
Jeff Washington (jwash) a44b080b7f
add partitioned_rewards_feature_enabled (#32115) 2023-06-14 07:47:12 -07:00
Jeff Washington (jwash) 1fa73e778f
add deactivate_epoch_reward_status (#32114) 2023-06-14 07:46:34 -07:00
Jeff Washington (jwash) 2968587d42
add compare_with_partitioned_rewards (#32108) 2023-06-14 07:43:09 -07:00
Jeff Washington (jwash) 67a434fc5b
add calculate_rewards_for_partitioning (#32110) 2023-06-13 15:45:59 -07:00
Jeff Washington (jwash) 65268af497
pass get_reward_interval to load_accounts (#32084) 2023-06-13 14:49:07 -07:00
Jeff Washington (jwash) 9774826b08
add calculate_validator_rewards (#32107) 2023-06-13 14:45:19 -07:00
Jeff Washington (jwash) dcd66534dd
add partitioned rewards helpers (#32085)
* add partitioned rewards helpers

* remove pub(crate)

* credit -> distribution
2023-06-13 13:57:52 -07:00
Jeff Washington (jwash) 0762e69863
remove build error from merge (#32104) 2023-06-13 12:33:40 -07:00
Jeff Washington (jwash) 3fc183ca74
add calculate_stake_vote_rewards for partitioned rewards (#32066)
* add calculate_stake_vote_rewards for partitioned rewards

* check stake reward in test

* pr feedback

* add comment

---------

Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-06-13 11:53:30 -07:00
Jeff Washington (jwash) 446b82afba
update comment (#32099) 2023-06-13 10:54:38 -07:00
Jeff Washington (jwash) 7c5c70a522
add compare_with_partitioned_rewards_results for testing partitioned rewards (#32086) 2023-06-13 07:39:46 -07:00
Jeff Washington (jwash) b89ce94d33
add store_vote_accounts_partitioned (#32061)
* add store_vote_accounts_partitioned

* pr feedback
2023-06-12 14:38:30 -07:00
Tao Zhu 9b2c9b8f5a
correct feature gate use_default_units_in_fee_calculation usage (#32077) 2023-06-12 16:29:21 -05:00
Alexander Meißner d0ae8c38bd
Fix - `enable_alt_bn128_syscall` (#32083)
* Fixes test_runtime_feature_enable_with_program_cache.

* Adds enable_alt_bn128_syscall to FEATURES_AFFECTING_RBPF.
2023-06-12 22:37:02 +02:00
Jeff Washington (jwash) 6280c63e1a
epoch rewards are stored partitioned as Vec<Vec< (#32076)
* epoch rewards are stored partitioned as Vec<Vec<

* update comment
2023-06-12 13:06:22 -07:00
Jeff Washington (jwash) 7e7c286d50
factor out get_epoch_reward_calculate_param_info to share results (#32065)
* factor out get_epoch_reward_calculate_param_info to share results

* remove extra comment
2023-06-12 09:56:08 -07:00
steviez 2e5b062809
Display path in error message when file create/write fails (#32036)
Using .unwrap() will panic and display the error; however, the path
isn't displayed which makes debugging harder.
2023-06-12 11:45:26 -05:00
Jeff Washington (jwash) 0645e96bc6
add calc_vote_accounts_to_store (#32063)
* add calc_vote_accounts_to_store

* update comment
2023-06-12 08:38:18 -07:00
Jeff Washington (jwash) 26f4c405b2
add update_reward_history_in_partition (#32062)
* add update_reward_history_in_partition

* remove explicit type

* remove spurrious comment
2023-06-12 08:37:46 -07:00
Jeff Washington (jwash) b81a060898
add store_stake_accounts_in_partition (#32060)
* add store_stake_accounts_in_partition

* pr feedback on assert
2023-06-12 08:37:22 -07:00
Jeff Washington (jwash) a001c5eb49
add calculate_reward_points_partitioned (#32050)
* add calculate_reward_points_partitioned

* remove unnecessary clone

* add comment

* clean up test from pr feedback
2023-06-12 08:36:42 -07:00
Jeff Washington (jwash) 37efc82a76
snapshot epoch reward fields tests (#32064) 2023-06-12 07:39:59 -07:00
Jeff Washington (jwash) 2572df7452
stake tests modification: next_epoch_and_n_slots (#32052)
stake tests modification: next_epoch_and_n_slots
2023-06-11 12:26:16 -07:00
Jeff Washington (jwash) 4ebec905c5
add hash_rewards_into_partitions (#31795)
* add sort_and_shuffle_partitioned_rewards

* break stake accounts into partitions by hashing

* fmt

* Update runtime/src/epoch_rewards_hasher.rs

Co-authored-by: Trent Nelson <trent.a.b.nelson@gmail.com>

* Update runtime/src/bank/tests.rs

Co-authored-by: Trent Nelson <trent.a.b.nelson@gmail.com>

* Update runtime/src/bank/tests.rs

Co-authored-by: Trent Nelson <trent.a.b.nelson@gmail.com>

* Update runtime/src/bank.rs

Co-authored-by: Trent Nelson <trent.a.b.nelson@gmail.com>

* fix build

* more build fixes

* use spihasher13 for reward partition

* update comments

* revert calc reward struct change to avoid abi changes for now

* cippy

* sort deps

* saturating math

* use copy traits on hasher
use parent block hash to seed rewards partition

* fmt

* use concurrent map to speed up reward partition

* clippy

* Update runtime/src/epoch_rewards_hasher.rs

Co-authored-by: Trent Nelson <trent.a.b.nelson@gmail.com>

* Update runtime/Cargo.toml

Co-authored-by: Trent Nelson <trent.a.b.nelson@gmail.com>

* Update runtime/src/bank.rs

Co-authored-by: Trent Nelson <trent.a.b.nelson@gmail.com>

* rename

* address review comments

* cargo.lock

* Update runtime/src/bank.rs

Co-authored-by: Trent Nelson <trent.a.b.nelson@gmail.com>

* update test

* clippy

* comments

* move hash_address_to_partition to epoch_rewards_hasher.rs

* tests to nail down width of partitions

* rename parameter to match with comments

* hash_address takes &self

* clippy

* EpochRewardHasher -> EpochRewardsHasher

* revert "hash_address takes &self" and refactor

* stake_rewards takes by value

---------

Co-authored-by: HaoranYi <haoran.yi@gmail.com>
Co-authored-by: Trent Nelson <trent.a.b.nelson@gmail.com>
Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-06-09 11:55:01 -07:00
Jeff Washington (jwash) 14e90cb27d
test ancient packing with recycling (#32021)
* test ancient packing with recycling

* fix holdover from debugging and update comment
2023-06-09 10:38:34 -07:00
Andrew Fitzgerald 4a566ec938
create and canonicalize account_paths (#32037)
Co-authored-by: Brooks <brooks@prumo.org>
2023-06-09 10:04:25 -07:00
Brooks 948b66ee95
Removes #[allow(dead_code)] from ancient_append_vecs.rs (#32047) 2023-06-09 16:47:24 +00:00
Jeff Washington (jwash) 4fde0b0d4a
remove packed ancient append vec from shrink candidate list (#32022) 2023-06-09 09:28:49 -07:00
Jeff Washington (jwash) 31f2f569a6
simplify clean_dead_slot, factor out root stats (#32035) 2023-06-09 07:35:38 -07:00
Brooks afbb0fa92f
Removes init-time cleanup in add_bank_snapshot() (#31997) 2023-06-09 08:30:35 -04:00
Andrew Fitzgerald bfe171017c
move cost model tests (#32034) 2023-06-08 15:02:28 -07:00
Yueh-Hsuan Chiang 7cea6dd57c
[TieredStorage] ByteBlockWriter::write_optional_fields (#32025)
#### Summary of Changes
This PR implements the writer function for AccountMetaOptionalFields
in ByteBlockWriter::write_optional_fields().

#### Test Plan
Unit tests are included in this PR.
Tested in mnb w/ the prototype implementation of the tiered storage (#30626)
2023-06-08 14:09:01 -07:00
Yueh-Hsuan Chiang 634f925d75
[TieredStorage] AccountMetaOptionalFields (#32005)
#### Summary of Changes
This PR introduces AccountMetaOptionalFields, the in-memory struct for
handling optional fields.

#### Test Plan
Unit tests are included in this PR.
Tested in mnb w/ the prototype implementation of the tiered storage (#30626).
2023-06-08 12:31:27 -07:00
Andrew Fitzgerald 3ba05d9c3d
Fix move_and_async_delete_path (#32020) 2023-06-08 10:55:52 -07:00
steviez 4b2db0d546
Add explaining comment for Err case in get_bank_snapshots() (#31998) 2023-06-08 12:54:24 -05:00
Tao Zhu 37a759045a
include cost of transaction's requested loaded accounts size in cost model (#31905)
* include transaction requested loaded accounts size cost in cost model

* move function to avoid circular dependency
2023-06-08 12:49:42 -05:00
Jeff Washington (jwash) 8937fd9bd6
improve packed ancient test by sweeping (#32002) 2023-06-08 07:50:18 -07:00
Alexander Meißner 3f13cd353e
Fix - LoadedProgramType::Closed (#31922)
* Makes Bank::load_program() return correct tombstones.

* Removes early TX failure caused by closed and invalid programs.

* Adjusts the feature gate of simplify_writable_program_account_check.
2023-06-08 15:40:18 +02:00
Brooks ddbc35fcc3
Add logging to move_and_async_delete_path (#32017) 2023-06-07 16:31:16 -04:00
Jeff Washington (jwash) 36ccc71220
move StakeReward to stake_rewards.rs (#32014) 2023-06-07 12:35:28 -07:00
Alexander Meißner c87ff8780a
Cleanup - `Bank::reconfigure_token2_native_mint()` (#31817)
Removes Bank::reconfigure_token2_native_mint().
2023-06-07 21:14:43 +02:00
Yueh-Hsuan Chiang b1db4ccc9a
[TieredStorage] Make AccountMetaFlags and its fields public (#32004)
#### Problem
AccountMetaFlags and its fields are required to be public as the visibility of their get
functions generated by `bit_fields` are tied to the visibility of their fields, and the
get functions will later be used to support the TieredAccountMeta for AccountMeta.

#### Summary of Changes
Make AccountMetaFlags and its fields public
2023-06-07 11:37:56 -07:00
Jeff Washington (jwash) 0f215575ca
add RewardInterval::InsideInterval (#31799)
* add RewardInterval::InsideInterval

* update abi hash

---------

Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-06-07 09:56:36 -07:00
Alexander Meißner ee2c2ef6c7
Cleanup - require_static_program_ids_in_transaction (#31767)
require_static_program_ids_in_transaction
2023-06-07 17:12:41 +02:00
Pankaj Garg c86e160438
Add runtime environment to FailedVerification tombstones (#31991)
* Add runtime environment to FailedVerification tombstones

* modify default variant

* prune update

* add DelayVisibility in prune_feature_set_transition
2023-06-06 22:24:39 +00:00
Jeff Washington (jwash) 85a0e31c60
add ProgramExecutionTemporarilyRestricted error (#31796)
* add StakeProgramUnavailable error

* rename to ProgramExecutionTemporarilyRestricted

* Update sdk/src/transaction/error.rs

Co-authored-by: Trent Nelson <trent.a.b.nelson@gmail.com>

* fmt

* update frozen abi hash

* add account_index to ProgramExecutionTemporarilyRestricted error

* Update sdk/src/transaction/error.rs

Co-authored-by: mvines <mvines@gmail.com>

* populate transaction_details from transaction_error for ProgramExecutionTemporarilyRestricted error

* fix a test

* update abi digest

* Update sdk/src/transaction/error.rs

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

---------

Co-authored-by: Trent Nelson <trent.a.b.nelson@gmail.com>
Co-authored-by: HaoranYi <haoran.yi@solana.com>
Co-authored-by: HaoranYi <haoran.yi@gmail.com>
Co-authored-by: mvines <mvines@gmail.com>
Co-authored-by: Brooks <brooks@prumo.org>
2023-06-06 14:13:41 -07:00
Tao Zhu 71c78f7a21
Will failed transaction should be considered has zero execution cost by cost model (#31976) 2023-06-06 15:45:45 -05:00
Brooks f08fb3e158
Downgrades log to debug if reading bank snapshot from dir fails (#31990) 2023-06-06 15:07:45 -04:00
Tao Zhu 83ac66caa1
split TransactionCost to its own module (#31977)
* split TransactionCost to its own module

* remove unused function
2023-06-06 11:15:38 -05:00
Alexander Meißner 89207a3fe5
Feature - Prune on feature set transition (#31945)
* Call create_program_runtime_environment() in Bank::apply_builtin_program_feature_transitions().

* Adds LoadedPrograms::prune_feature_set_transition().
2023-06-06 17:49:02 +02:00
Yueh-Hsuan Chiang 40d3e8e8fa
[TieredStorage] Enable ByteBlockWriter to report the length of raw data (#31900)
#### Summary of Changes
This PR adds raw_len() to ByteBlockWriter which returns
the length of the data after decoding.  This information is needed
for the cold storage to keep track of the current size of the account
block after decompression.

#### Test Plan
Improved existing tests to verify the returned raw_len().
Tested in mnb w/ the prototype implementation of the tiered storage (https://github.com/solana-labs/solana/pull/30626)
2023-06-02 14:01:38 -07:00
Pankaj Garg 37ebb709e6
Evict program cache using transaction usage counter (#31927)
* Evict program cache using tx usage counter

* address review feedback

* address review feedback
2023-06-02 11:26:56 -07:00
Tao Zhu 10995f66c0
use one definition of builtin program cost in runtime and banking stage (#31930)
* use one definition of builtin program cost in runtime and banking stage
* add loader_v4
2023-06-02 10:22:22 -05:00
steviez 858ea5a143
chore: Add name string for bank_serialize measure! (#31926)
The measurement is later logged, so include a name to more clearly
identify what the measurement was.
2023-06-02 06:54:04 -05:00
Pankaj Garg 29d7a57cce
Reset program cache stats after submit (#31929) 2023-06-02 01:16:49 -07:00
Illia Bobyr 4353ac6797
Pass Arc<AtomicBool> by value, not by reference. (#31916)
`Arc` is already a reference internally, so it does not seem to be
beneficial to pass a reference to it.  Just adds an extra layer of
indirection.

Functions that need to be able to increment `Arc` reference count need
to take `Arc<AtomicBool>`, but those that just want to read the
`AtomicBool` value can accept `&AtomicBool`, making them a bit more
generic.

This change focuses specifically on `Arc<AtomicBool>`.  There are other
uses of `&Arc<T>` in the code base that could be converted in a similar
manner.  But it would make the change even larger.
2023-06-01 17:25:48 -07:00
Yueh-Hsuan Chiang 2b04f28c7b
[TieredStorage] AccountMetaFlags (#31913)
#### Summary of Changes
This PR implements AccountMetaFlags, which will later be used in
the tiered accounts storage to support optional fields.

#### Test Plan
Unit tests are included in this PR.
2023-06-01 14:48:27 -07:00
Yueh-Hsuan Chiang 1302962521
[TieredStorage] Support Lz4 in ByteBlockWriter (2/N) (#31862)
#### Summary of Changes
Support Lz4 in ByteBlockWriter.

#### Test Plan
Added test cases for Lz4.
Tested in mnb w/ the prototype implementation of the tiered storage (#30626)
2023-06-01 10:29:08 -07:00
steviez debe794987
Replace improper &Arc<...> with Arc<...> in Bank and Accounts (#31892)
The callstack updated in this PR passed an &Arc<...> down only to have
the bottom level clone the reference. Thus, we are giving shared
ownership so the reference is a bit redundant and arguably obscures the
intention to clone further down the callstack.
2023-05-31 12:36:44 -05:00
Brooks 8e191bbc56
Downgrades log to warn if reading bank snapshot from dir fails (#31885) 2023-05-30 19:35:06 -04:00
Yueh-Hsuan Chiang 33d64c6b2f
[TieredStorage] Add doc comments for byte_block.rs (#31863)
#### Summary of Changes
Add doc comments for byte_block.rs

#### Test Plan
This is a comment-only PR.  No code change.
2023-05-30 16:25:25 -07:00
Brooks c569a37713
Handle errors when sending an accounts package during shutdown (#31874) 2023-05-30 17:42:33 -04:00
Yueh-Hsuan Chiang 5334efd63c
Byte-blocks utils for TieredStorage (1/N) (#31815)
#### Summary of Changes
This PR includes the util structs for writing byte blocks, which will be used
by the TieredStorage writer (currently used in the prototype #30626).

The PR only includes the Raw encoding format.  Will add more in subsequent PRs.

#### Test Plan
Tested in mnb with the prototype implementation of the tiered-storage (#30626)
Unit tests are also included in this PR.
2023-05-30 14:14:29 -07:00
Jeff Washington (jwash) 6c520396cd
bank process_new_epoch takes parent_height (#31820) 2023-05-30 08:58:40 -05:00
Jeff Washington (jwash) 588a7a4e53
add RewardsStoreMetrics for partitioned rewards (#31819) 2023-05-30 08:58:00 -05:00
Jeff Washington (jwash) 0c64e26d53
partitioned rewards helper functions (#31818) 2023-05-30 08:57:31 -05:00
Brooks 8a3f446db0
Removes MAX_BANK_SNAPSHOTS_TO_RETAIN constant (#31827) 2023-05-25 17:13:28 -04:00
Andrew Fitzgerald 75954dc061
Banking worker (#30970) 2023-05-25 10:16:04 -07:00
Brooks 0e93090520
Updates priority for which snapshot request to handle next (#31798) 2023-05-24 16:21:06 -04:00
Yueh-Hsuan Chiang 6752019a80
Add enum AppendVecError (#31749)
#### Problem
AppendVec currently uses std::io::ErrorKind::Other for its own errors.

#### Summary of Changes
This PR introduces AppendVecError and has AppendVec use it.
2023-05-24 12:18:17 -07:00
Jeff Washington (jwash) 461342cdd4
add cli args and use of partitioned rewards config (#31800)
* add cli args and use of partitioned rewards config

* update comments
2023-05-24 10:54:09 -07:00
Jeff Washington (jwash) 49259dcad8
add optional ignore to `calculate_accounts_delta_hash` (#31801) 2023-05-24 10:51:03 -07:00
Jeff Washington (jwash) d6a54e0f4d
add partitioned_rewards.rs (#31794) 2023-05-24 09:59:38 -07:00
Alexander Meißner a85548cf34
Cleanup - spl_token_v3_4_0 and spl_associated_token_account_v1_1_0 (#31764)
* spl_token_v3_4_0

* spl_associated_token_account_v1_1_0

* Marks replace_program_account() as dead code.
2023-05-24 18:45:37 +02:00
Jeff Washington (jwash) e396a10312
change StartBlockHeightAndRewards from parent to current (#31781) 2023-05-23 20:10:51 -07:00
Jeff Washington (jwash) ae12079139
add debug to VoteReward (#31782) 2023-05-23 20:10:20 -07:00
Jeff Washington (jwash) 8e8b2f1671
reformat comments (#31780) 2023-05-23 17:04:47 -07:00
Andrew Fitzgerald f52ded35f4
async delete contents but leave directory (#31737)
* async delete contents but leave directory

* Clarified comment
2023-05-23 15:33:09 -07:00
Brooks 05c932f92d
Moves transient accounts hash cache files into their own dir (#31778) 2023-05-23 22:14:30 +00:00
Yueh-Hsuan Chiang 174951478f
Add new error type -- TieredStorageError (#31633)
#### Summary of Changes
This PR adds a new error type for the tiered storage.
2023-05-23 15:06:55 -07:00
Brooks a474cb24b9
Creates temporary accounts hash cache files inside accounts hash cache dir (#31776) 2023-05-23 17:09:16 -04:00
Brooks 61afb07dbd
Purges old bank snapshots at startup (#31656)
Co-authored-by: Andrew Fitzgerald <apfitzge@gmail.com>
2023-05-23 13:18:05 -04:00
Andrew Fitzgerald 5448d0b1e8
Remove redundant clones (#31685)
* broadcast_stage remove redundant clone

* broadcast_fake_shreds_run remove redundant clone

* wallet remove redundant clone

* cluster_query remove redundant clone

* accounts remove redundant clones
2023-05-23 09:42:05 -07:00
Alexander Meißner 1e8e024ec5
Cleanup - disable_fee_calculator (#31766)
disable_fee_calculator
2023-05-23 18:20:38 +02:00