Commit Graph

88 Commits

Author SHA1 Message Date
Jon Cinque c73a56faf8
stake: Rename `StakeStateWithFlags` -> `StakeStateV2` (#32795) 2023-08-11 01:07:21 +02:00
Pankaj Garg f4287d70bb
Move accounts-db code to its own crate (#32766) 2023-08-09 13:03:36 -07:00
Jon Cinque 8e4a9a94ed
sdk: Add new version of `StakeState` to avoid breaking downstream users (#32736)
* sdk: Rename `StakeState` -> `StakeStateWithFlags`

* Add back `StakeFlags` with a deprecation warning
2023-08-09 00:05:40 +02:00
Ashwin Sekar fa3506631a
stake: deprecate on chain warmup/cooldown rate and config (#32723)
* stake: deprecate on chain warmup/cooldown rate and config

* Pr feedback: Deprecate since 1.16.7

Co-authored-by: Jon Cinque <me@jonc.dev>

---------

Co-authored-by: Jon Cinque <me@jonc.dev>
2023-08-07 13:23:24 -07:00
behzad nouri 952d8861c6
removes feature-gate code for updating rewards from cached accounts (#32514) 2023-07-21 19:52:44 +00:00
HaoranYi 5408872476
test force reward interval end fn (#32513)
Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-07-17 15:37:10 -05:00
Pankaj Garg 2a86420777
Move calculate_fee() out of bank.rs (#32409)
* Move calculate_fee() to fee.rs

* fixup code for compilation
2023-07-14 20:17:38 -07:00
Pankaj Garg 7177dd9809
Remove calculate_fee()'s dependency on ComputeBudget (#32487) 2023-07-14 12:25:04 -07:00
HaoranYi ae6abda786
Remove unnecessary dead_code attributes (#32416)
* remove unnecessary dead_code attr

* move test fn to test files

---------

Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-07-12 18:41:17 -05:00
Justin Starry d344ae5297
feature flag cleanup: fix_recent_blockhashes (#32443)
* feature flag cleanup: fix_recent_blockhashes

* flip test logic
2023-07-11 20:43:50 -05:00
HaoranYi 466564686b
update epoch rewards sysvar (#32415)
* update epoch rewards sysvar

* add back the one reward distribution reward test

---------

Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-07-11 11:24:20 -05:00
HaoranYi 943fba5afd
update max reward block factor (#32445)
* update max reward block factor

* review comments

* more tests

* reduce the number of stakes per block to speed up tests

---------

Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-07-11 09:36:11 -05:00
HaoranYi a3171d3de2
Fix typos (#32420)
* typo

* more typos

---------

Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-07-07 21:05:32 +00:00
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
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 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
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
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
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
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
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
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
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
Jeff Washington (jwash) b1b7ae5e09
cleanup math in distribute_partitioned_epoch_rewards (#32164) 2023-06-15 16:17:38 -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) 1fa73e778f
add deactivate_epoch_reward_status (#32114) 2023-06-14 07:46:34 -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) 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) b89ce94d33
add store_vote_accounts_partitioned (#32061)
* add store_vote_accounts_partitioned

* pr feedback
2023-06-12 14:38:30 -07: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) 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
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) 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
Andrew Fitzgerald bfe171017c
move cost model tests (#32034) 2023-06-08 15:02:28 -07: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
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
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
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
Alexander Meißner e9d99973ca
Cleanup - bank_transaction_count_fix (#31768)
bank_transaction_count_fix
2023-05-23 18:18:15 +02:00
Alexander Meißner 83f692ce67
Refactor - Share RBPF config and syscall registry globally (#31727)
* Adds LoadedPrograms::program_runtime_environment_v1.

* No need to explicitly remove precompiles from program_accounts_map.
2023-05-20 20:28:00 +02:00
Pankaj Garg e6d490708a
Do not overwrite builtin program in the same slot (#31718) 2023-05-19 05:26:31 -07:00
Alexander Meißner 520c647918
Refactor - Merges `BuiltinPrograms` into `LoadedPrograms` (#31654)
* Merges BuiltinPrograms into LoadedPrograms.

* Prevents built-ins from being pruned.
2023-05-18 22:18:28 +02:00
Pankaj Garg b03422968b
Remove Rc and RefCell to carry program cache in invoke_context (#31684) 2023-05-17 06:10:50 -07:00