Commit Graph

115 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
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
steviez c98c24bd6d
Revert "Split compute budget instructions process from struct itself … (#33784)
Revert "Split compute budget instructions process from struct itself (#33513)"

This reverts commit c73bebe984. This
was found to be a consensus breaking change.
2023-10-20 15:53:45 +02:00
Tao Zhu c73bebe984
Split compute budget instructions process from struct itself (#33513)
* Split compute budget instruction processing from ComputeBudget struct itself, allow compute_budget_instructions be processed elsewhere without having to instantiate ComputeBudget

* updated tests
2023-10-19 11:10:42 -05:00
Brooks c1353e172c
Removes cap_accounts_data_allocations_per_transaction featurization (#33754) 2023-10-19 07:01:15 -04:00
Alexander Meißner a3f85aba21
Refactor - LoadedPrograms part 2 (#33694) 2023-10-13 12:59:48 -07:00
Sean Young 47511999bb
bank: do not remove trailing 0 bytes from return data (#33639)
This is creating havoc for Solang, as the return data is borsh encoded
and therefore `u64` values like 0x100 get truncated.
2023-10-13 08:00:41 +01:00
Ryo Onodera 53925b6182
Make goto_end_of_slot() take Arc<Bank> (#33650) 2023-10-13 13:08:38 +09:00
Brooks 452fd5d384
Adds `--no-skip-initial-accounts-db-clean` *hidden* CLI flag (#33664) 2023-10-12 13:32:40 -04:00
Brennan b36d051b51
Update hashes per tick with feature gates (#33600)
* Update hashes per tick with feature gates
2023-10-11 09:58:06 -07:00
Alexander Meißner cb695c7b32
Cleanup - Feature Gate of `enable_early_verification_of_account_modifications` (#33579)
Cleans up the feature gate of enable_early_verification_of_account_modifications:
- Removes PreAccount
- Removes InvokeContext::pre_accounts and InvokeContext::rent
- Removes InvokeContext::verify() and InvokeContext::verify_and_update()
- Removes TransactionContext::is_early_verification_of_account_modifications_enabled()
- Removes TransactionAccounts::is_early_verification_of_account_modifications_enabled
- No longer optional: TransactionContext::rent
2023-10-10 17:26:17 +02: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
Joe C 25460f76e7
Bank: Add function to replace empty account with upgradeable program on feature activation (#32783)
* replace program account

* modify for all cases

* remove non-data swap

* address tests & conditional feedback

* get the rent involved

* mix in owner & executable

* feature-related cases

* stripped back to feature-specific case only

* added feature

* address initial feedback

* added more lamport checks

* condense tests

* using test_case

* add fail cases to tests

* more cleanup

* add verifiably built program

* update program account state

* cleaned up serializing logic

* use full word capitalization

* rename old & new to dst & src

* swap src and dst in parameters

* add warnings and errors

* rename feature to programify

* test suite description clarity

* remove strings from datapoints

* spell out source and destination

* more verbose comments in account replace functions

* move lamport calculation

* swap lamport check for state check

* move replace functions to helper module

* make replace_account methods fallible

* refactor error handling

* add test for source program state
2023-10-04 19:54:59 +02:00
Trent Nelson 1840fd7ab3
Feature - better error codes for tx lamport check (#33343)
Replaces `TransactionError::InstructionError(0, InstructionError::UnbalancedInstruction)` with `TransactionError::UnbalancedTransaction`.

Co-authored-by: Alexander Meißner <AlexanderMeissner@gmx.net>
2023-09-22 23:58:05 +00:00
Tao Zhu a2ad820309
compute_budget heap_size does not have to be optional (#33313) 2023-09-21 09:24:47 -05:00
Tao Zhu 8b8a21a52f
cleanup feature: enable request heap frame instruction #30076 (#33243)
* cleanup feature: enable request heap frame instruction #30076

* update sbf tests

* removed out dated comments and test
2023-09-18 16:06:24 -05:00
Pankaj Garg 5562f79cc5
Do not unnecessarily re-verify unloaded program (#32722)
* Do not unnecessarily re-verify unloaded program

* clippy fixes

* new unit test for extract

* fixes after rebase

* fixes after rebase

* address review comments

* fix clippy
2023-09-13 06:25:56 -07:00
Brooks 9e156f88f4
Removes invariant `is_serialized_with_abs` param (#33154) 2023-09-06 12:00:18 -04:00
steviez 224eea42d5
Add unit test for Bank::register_hard_fork() (#32902) 2023-09-06 09:07:09 -05:00
Ryo Onodera 4fe0812f3c
Make should_panic tests compatible with 1.73+ panic format (#33099)
* Adjust should_panic tests for 1.73+ panic format

* Update more panic format change affected tests...
2023-09-01 02:04:22 +00:00
behzad nouri 4ec5ea6f7b
replaces assert!(matches!(...)) with assert_matches!(...) (#33068)
assert_matches!(...) provides more informative error message when it
fails and it is part of nightly rust:
https://doc.rust-lang.org/std/assert_matches/macro.assert_matches.html
2023-08-30 13:48:27 -04: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
steviez cd96d5b6c3
Only update last restart slot sysvar if value has changed (#32925)
Read account first to check for change in value
2023-08-22 22:33:03 +02: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
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
Brooks 280bb53802
Adds docs to get_all_accounts() (#32887) 2023-08-18 16:09:50 +00:00
Alexander Meißner c5a251e8c3
Refactor - `Bank::compute_active_feature_set()` (#32872)
Returns the feature set instead of overwriting it inside Bank::compute_active_feature_set().
2023-08-17 19:14:10 +02:00
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