Commit Graph

145 Commits

Author SHA1 Message Date
Michael Vines b05c7d91ed Fix derive_partial_eq_without_eq clippy lint 2022-05-22 22:22:21 -07:00
Brooks Prumo e6c02f30dd
Raise minimum stake delegation to 1 SOL (#24603) 2022-05-07 19:01:05 -04:00
Jon Cinque 326e53be97
stake: Allow initialized stakes to be below the min delegation (#24670)
* stake: Allow initialized stakes to be below the min delegation

* Add PR number in feature

* Fixup RPC subscription test

* Address feedback pt 1

* Address feedback pt 2

* Update FrozenAbi Digest

* Address feedback: no new error type, more comments
2022-05-04 12:17:29 +02:00
Tyera Eulberg db32549c00
Convert tuples to structs in Stake rewards-calculation functions (#24681)
* Replace opaque tuples with structs in Stake rewards calculation

* Fixup struct and field names, and remove one cumbersome destructuring
2022-04-27 07:44:10 +00:00
Ryo Onodera 412a5a0d33
Credits auto rewind on vote recreation (#22546)
* Credits auto rewind on vote recreation

* Update comment

* Improve comments and tests

* Recommended fn rename

* Restore old feature, and replace new feature key

Co-authored-by: Tyera Eulberg <tyera@solana.com>
2022-04-26 15:49:35 -06:00
Justin Starry 2ad1baa753
Add const fn StakeState::size_of and static assertion (#24416) 2022-04-20 01:04:12 +08:00
Michael Vines 57ff7371b4 Add StakeInstruction::DeactivateDelinquent 2022-04-14 01:49:22 -04:00
Alexander Meißner bf13fb4c4b
Remove `KeyedAccount` in builtin program "stake" (#24210)
* Inline keyed_account_at_index() in all instructions of stake
which have more than one KeyedAccount parameter,
because these could cause a borrow collision.

* Uses transaction_context.get_key_of_account_at_index() in stake.

* Refactors stake::config::from to use BorrowedAccount instead of ReadableAccount.

* Replaces KeyedAccount by BorrowedAccount in stake.
2022-04-10 09:55:37 +02:00
Alexander Meißner fad9bd0538
Removes KeyedAccount parameter from get_if_mergeable(). (#24190) 2022-04-08 20:40:09 +02:00
Alexander Meißner efb9cbd8e7
Refactor: Remove `trait` from stake keyed account (#24148)
Removes trait from StakeAccount.
2022-04-06 22:58:09 +02:00
Alexander Meißner 07f4a9040a
Removes KeyedAccount from tests in stake instruction. (Part 4) (#24124)
* Moves tests from stake state to stake instruction.

* Migrates test_merge.

* Migrates test_merge_self_fails.

* Migrates test_merge_incorrect_authorized_staker.

* Migrates test_merge_invalid_account_data.

* Migrates test_merge_fake_stake_source.

* Migrates test_merge_active_stake.
2022-04-06 12:04:35 +02:00
Alexander Meißner e051c7c162
Removes KeyedAccount from tests in stake instruction. (Part 3) (#24110)
* Moves test from stake state to stake instruction.

* Migrates test_split_source_uninitialized.

* Migrates test_split_split_not_uninitialized.

* Migrates test_split_more_than_staked.

* Migrates test_split_with_rent.

* Migrates test_split_to_account_with_rent_exempt_reserve.

* Migrates test_split_from_larger_sized_account.

* Migrates test_split_from_smaller_sized_account.

* Migrates test_split_100_percent_of_source.

* Migrates test_split_100_percent_of_source_to_account_with_lamports.

* Migrates test_split_rent_exemptness.
2022-04-05 12:36:01 +02:00
Brooks Prumo 2af6753808
Add GetMinimumDelegation stake program instruction (#24020) 2022-04-02 05:11:10 +00:00
Alexander Meißner 8a18c48e47
Removes `KeyedAccount` from tests in stake instruction. (Part 2) (#24053)
* Migrates test_initialize_minimum_stake_delegation.

* Migrates test_delegate_minimum_stake_delegation.

* Migrates test_split_minimum_stake_delegation.

* Migrates test_split_full_amount_minimum_stake_delegation.

* Migrates test_split_destination_minimum_stake_delegation.

* Migrates test_withdraw_minimum_stake_delegation.

* Migrates test_behavior_withdrawal_then_redelegate_with_less_than_minimum_stake_delegation.
2022-04-02 01:08:55 +02:00
Justin Starry cb5e67d327
Use Rent sysvar directly for stake split instruction (#24008)
* Use Rent sysvar directly for stake split ix

* Add feature to gate rent sysvar change

* fix tests

* cargo clippy
2022-03-31 16:46:35 +08:00
Brooks Prumo 18bddbc730
Stake tests respect MINIMUM_STAKE_DELEGATION (#23426) 2022-03-16 16:36:23 -05:00
Brooks Prumo 74bb527203
Refactor and use MINIMUM_STAKE_DELEGATION constant (#22663) 2022-03-16 10:56:48 -05:00
Alexander Meißner e60c9b97c9
Removes `KeyedAccount` from tests in stake instruction. (Part 1) (#23473)
* Migrates test_stake_delegate().

* Migrates test_stake_initialize().

* Migrates test_initialize_incorrect_account_sizes().

* Migrates test_authorize().

* Migrates test_authorize_lockup().

* Migrates test_authorize_override().

* Migrates test_authorize_with_seed().

* Migrates test_split().

* Migrates test_split_fake_stake_dest().

* Migrates test_deactivate().

* Migrates test_set_lockup().

* Migrates test_optional_lockup_for_stake_program().

* Migrates test_withdraw_stake().

* Migrates test_withdraw_stake_invalid_state().

* Migrates test_withdraw_stake_before_warmup().

* Migrates test_withdraw_lockup().

* Migrates test_withdraw_identical_authorities().

* Migrates test_withdraw_rent_exempt().

* Migrates test_authorize_delegated_stake().

* Migrates test_redelegate_consider_balance_changes().
2022-03-09 23:48:10 +01:00
Brooks Prumo 79a515e88e
Add tests for split() from Uninitialized account where dest=source (#23442) 2022-03-02 18:32:15 -06:00
Brooks Prumo e87b941a51
Test stake split: destination delegation is at least the minimum (#23456) 2022-03-02 17:29:40 -06:00
Brooks Prumo fcaf01e243
Add test to check destination for stake splitting (#23303) 2022-02-23 22:47:57 -06:00
Brooks Prumo ac70070e5b
Add MINIMUM_STAKE_DELEGATION constant (#23259)
Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2022-02-22 09:21:23 -06:00
Ryo Onodera 545c97f903
Clean up before credits_auto_rewind (#22839)
* Clean up before credits_auto_rewind

* Use `=` intead of `|=` for mutable bool
2022-02-01 22:42:02 +09:00
Brooks Prumo 3993cd765c
Remove rewrite_rent_exempt_reserve() (#22741) 2022-01-26 18:42:44 -05:00
Brooks Prumo a7f2fff219
Remove active features stake program v3 and v4 (#22612)
Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
2022-01-21 19:27:53 -06:00
Alexander Meißner b448472037
Refactor: Move `InstructionRecorder` into `TransactionContext` (#22578)
* Moves InstructionRecorder into TransactionContext.

* Adds assertions for number_of_instructions_at_transaction_level.
2022-01-19 22:40:09 +01:00
Alexander Meißner 73e6038986
Refactor: Remove `KeyedAccount` from program runtime (#22226)
* Makes error handling in BorrowedAccount optional.
Adds BorrowedAccount ::get_rent_epoch().
Exposes InstructionContext::get_index_in_transaction().
Turns accounts and account_keys into pinned boxed slices.

* Introduces "unsafe" to InvokeContext::push().

* Turns &TransactionContext into &mut TransactionContext in InvokeContext.

* Push and pop InstructionContext in InvokeContext.
Makes test_process_cross_program and test_native_invoke symmetric.
Removes the borrow check from test_invoke_context_verify.

* Removes keyed_accounts from prepare_instruction()

* Removes usage of invoke_stack.

* Removes keyed_accounts from program-test.

* Removes caller_write_privileges.

* Removes keyed_accounts from BPF parameter (de-)serialization.
2022-01-03 23:30:56 +01:00
Alexander Meißner a06646631c
Feature: TransactionContext, InstructionContext and BorrowedAccount (#21706)
* Adds TransactionContext, InstructionContext and BorrowedAccount.

* Redirects the usage of accounts in InvokeContext through TransactionContext.
Also use the types declared in transaction_context.rs everywhere.

* Adjusts all affected tests.
2021-12-27 18:49:32 +01:00
Justin Starry 1430b58a6d
Remove deprecated slow epoch boundary methods (#21568) 2021-12-03 17:59:10 +00:00
Michael Vines b8837c04ec Reformat imports to a consistent style for imports
rustfmt.toml configuration:
  imports_granularity = "One"
  group_imports = "One"
2021-12-03 09:19:13 -08:00
Alexander Meißner a9d5ef2055
Cleanup: InvokeContext accessors (#21574)
* Removes blockhash accessors from InvokeContext.

* Removes lamports_per_signature accessors from InvokeContext.

* Removes return_data accessors from InvokeContext.

* Removes feature_set accessor from InvokeContext.

* Removes instruction_recorders and instruction_index accessors from InvokeContext.

* Moves get_sysvars() into InvokeContext.

* Removes compute_meter parameter from InvokeContext::new().

* Removes InvokeContext::new_mock_with_sysvars_and_features().

* Removes InvokeContext::update_timing().
2021-12-03 12:15:22 +01:00
Alexander Meißner bfdb775ffc
Unifies ThisInvokeContext and dyn trait InvokeContext. (#21563) 2021-12-02 18:47:16 +01:00
Brooks Prumo cb368e6554
Pass Epoch by value in StakeHistory::get() (#21523) 2021-12-01 08:57:29 -06:00
Ikko Ashimine d12dfc1918
Refactor: Fix typo in stake_state.rs (#21343)
initalize -> initialize
2021-11-18 09:58:56 -07:00
Alexander Meißner e540b1cf3c
Refactor: Move sdk::process_instruction in program-runtime-crate (#21180)
* Moves the Executor dyn Trait to instruction_processor.rs

* Moves the Logger dyn Trait as well as the ic_msg and ic_logger_msg macros to log_collector.rs,
and moves the stable_log to stable_log.rs

* Moves the ComputeMeter dyn Trait to invoke_context.rs

* Moves the InvokeContext dyn Trait and the ProcessInstructionWithContext type to invoke_context.rs

* Updates cargo files.

* Re-export InvokeContext in program-test

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
2021-11-17 19:35:07 +01:00
Alexander Meißner 7200c5106e
Replaces MockInvokeContext by ThisInvokeContext in tests (#20881)
* Replaces MockInvokeContext by ThisInvokeContext in BpfLoader, SystemInstructionProcessor, CLIs, ConfigProcessor, StakeProcessor and VoteProcessor.

* Finally, removes MockInvokeContext, MockComputeMeter and MockLogger.

* Adjusts assert_instruction_count test.

* Moves ThisInvokeContext to the program-runtime crate.
2021-11-04 21:47:32 +01:00
Alexander Meißner f30f3bddbb
Refactor: Remove program_id from process_instruction() (#20540)
* Replaces usage of program_id parameter by invoke_context.get_caller()?.

* Removes "pubkey: &Pubkey" parameter from "process_instruction()".
2021-10-10 22:29:18 +02:00
Justin Starry 129716f3f0
Optimize stakes cache and rewards at epoch boundaries (#20432)
* Optimize stakes cache and rewards at epoch boundaries

* Fetch from accounts db

* Add cli flag for disabling epoch boundary optimization
2021-10-06 00:53:26 -04:00
Justin Starry 250a8503fe
Make rewards tracer async friendly (#20452) 2021-10-05 21:30:08 -04:00
Justin Starry 0ddb34a0b4
Add struct and convenience methods to track stake activation status (#20392)
* Add struct and convenience methods to track stake activation status

* fix nits

* rename
2021-10-04 18:59:11 -04:00
Jon Cinque 2c3bdedea3
stake: Advance `credits_observed` on activation epoch (#19309)
* stake: Advance `credits_observed` on activation epoch

* Add test for merging stakes just after activation
2021-09-03 23:20:56 +02:00
Jon Cinque 73aa004c59
stake: Remove v2 program references (#19308)
* stake: Remove v2 program references

* Remove stake v2 feature, along with stake rewrite
2021-08-20 01:08:44 -04:00
Jon Cinque 2b33c0c165
stake: Allow stakes with unmatched credits observed to merge (#18985)
* stake: Allow stakes with unmatched credits observed to merge

* Address feedback

* Remove branch by doing a ceiling in one calc
2021-08-04 10:43:34 -04:00
Michael Vines 4098af3b5b Record vote account commission with voting/staking rewards and surface in RPC 2021-07-12 15:09:44 -07:00
Alexander Meißner 6514096a67 chore: cargo +nightly clippy --fix -Z unstable-options 2021-06-18 10:42:46 -07:00
Michael Vines 810fce1f3d Fix build issues downstream due to stake state shuffle 2021-06-17 23:59:05 -07:00
Michael Vines db37680f6f Add extra authorized withdrawer test 2021-06-16 18:26:25 -07:00
Jon Cinque 1b1d34da59
Refactor stake program into solana_program (#17906)
* Move stake state / instructions into solana_program

* Update account-decoder

* Update cli and runtime

* Update all other parts

* Commit Cargo.lock changes in programs/bpf

* Update cli stake instruction import

* Allow integer arithmetic

* Update ABI digest

* Bump rust mem instruction count

* Remove useless structs

* Move stake::id() -> stake::program::id()

* Re-export from solana_sdk and mark deprecated

* Address feedback

* Run cargo fmt
2021-06-15 18:04:00 +02:00
Michael Vines 96cde36784 SetLockup now requires the authorized withdrawer when the lockup is not in force 2021-05-21 11:49:01 -07:00
Trent Nelson 019bccab51 stake: merge accounts with mismatched, but expired lockups 2021-05-21 10:50:27 -06:00