Commit Graph

137 Commits

Author SHA1 Message Date
Jon Cinque c73a56faf8
stake: Rename `StakeStateWithFlags` -> `StakeStateV2` (#32795) 2023-08-11 01:07:21 +02: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
HaoranYi 17af3ab10a
Add stake_flags to stake state (#32524)
add stake_flags to stake state

Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-07-24 09:09:40 -05:00
Brooks 93d56c8eb2
Removes unnecessary borrows (#32498) 2023-07-14 11:45:40 -04:00
Jon Cinque 383063eeb2
stake: Remove `stake_allow_zero_undelegated_amount` usage (#32210) 2023-06-23 13:57:18 -07:00
Brooks ae65b35d9b
Removes StakeInstruction::GetMinimumDelegation featurization (#32121) 2023-06-14 19:01:17 -04:00
mvines 129b457c99
Remove StakeInstruction::DeactivateDelinquent featurization (#32045) 2023-06-09 22:56:13 -04: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
hana 07e038bceb
clean up delegation errors (#31202)
* Make delegation errors more descriptive

* Fix tests for StakeError::InsufficientDelegation
2023-04-14 15:30:59 -07:00
Alexander Meißner 0cd57addcf
Cleanup - mock_process_instruction() (#31088)
* Uses declare_process_instruction!() in all tests.

* Adds post_adjustments to mock_process_instruction().
Removes "solana_sbf_rust_external_spend" from assert_instruction_count() as it panics.
2023-04-07 12:53:19 +02:00
Alexander Meißner 24a87f33a8
Refactor - Cleanup error handling in program runtime (#30693)
* Moves stable_log::program_invoke(), stable_log::program_success() and stable_log::program_failure() calls from bpf_loader into InvokeContext::process_executable_chain().

* Turns result of ProcessInstructionWithContext from InstructionError into Box<dyn std::error::Error>.

* Bump to solana_rbpf v0.3.0

* Removes Result from return type of EbpfVm::new().

* Turns EbpfError into Box<dyn std::error::Error>.

* Removes BpfError.

* Removes SyscallError::InstructionError.

* Adds a type alias for Box<dyn std::error::Error> in syscalls.
2023-04-05 15:50:34 +02:00
Alexander Meißner a0c7fde90e
Cleanup - mock InvokeContext (#31007)
* Turns with_mock_invoke_context() into a macro.

* Removes prepare_mock_invoke_context().

* Replaces InvokeContext::new_mock() with with_mock_invoke_context().

* Removes InvokeContext::new_mock().

* Removes Cow from InvokeContext::sysvar_cache.

* Removes override parameters from mock_process_instruction().

* cargo fmt
2023-04-03 17:23:24 +02:00
Tao Zhu 3e500d9e92
Feature gate builtin consumes static units during processing instruction (#30702)
* add feature gate
* builtins consume statically defined units at beginning of process_instruction()
* Add new instructionError; return error if builtin did not consume units to enforce builtin to consume units;
* updated related tests
* updated ProgramTest with deactivated native_programs_consume_cu feature to continue support existing mock/test programs that do not consume units
2023-03-24 11:31:01 -05:00
Alexander Meißner 38e74325e3
Refactor - Remove `process_instruction` parameter `first_instruction_account` (#30579)
* Stops using first_instruction_account parameter in bpf_loader.

* Removes first_instruction_account parameter from process_instruction().
2023-03-06 17:37:37 +01:00
behzad nouri 12da2da389
fixes errors from clippy::redundant_clone (#29536)
https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone
2023-01-05 18:42:19 +00:00
Alexander Meißner 12d2147efa
Adds `IndexOfAccount` type (#27599)
Adds the type `IndexOfAccount`.
2022-09-06 11:31:40 +02:00
Alexander Meißner 6f2e556b16
Cleanup: `TransactionContext` (#27595)
* Lets instruction_accounts_lamport_sum() have the &InstructionContext as parameter directly.

* Updates docu comments.

* Uses accessors methods instead of accessing private properties of other structs.

* Adds #![deny(clippy::indexing_slicing)].

* Has get_signers() return a Result instead of using unwrap().

* Removes InvokeContext::get_key_of_account_at_index().
2022-09-05 16:29:02 +02:00
Michael Vines ccfbc54195 Move vote program state and instructions to solana-program 2022-08-09 20:52:47 -07:00
Tyera Eulberg 2481ebb150
Add explicit comment about get_stake_account to StakeInstruction enum (#26824)
Add explicit comment about get_stake_account
2022-07-27 20:44:52 -06:00
Michael Vines 48862c575a Add StakeInstruction::Redelegate 2022-07-27 20:24:25 -06:00
Alexander Meißner 075a5ac44e
Removes `AccountSharedData` from `SysvarCache`. (#26712)
* Removes AccountSharedData from SysvarCache.

* Fixes incorrect transaction account index in stake_instruction::test_set_lockup().
2022-07-21 18:32:28 +02:00
Brooks Prumo ef30f1729c
Cleanup stake_instruction tests (#26393) 2022-07-06 16:15:01 -05:00
Alexander Meißner c01a8f271e
Prepare built-in program tests to deal with stricter account modification checks (#26314)
* Fixes test_vote_state_withdraw().

* Set is_writable to true where needed.
2022-06-29 19:29:12 +02:00
Alexander Meißner bf9ca9827e
Refactor: instruction account index (#25825)
* Adds methods based on instruction_account_index to InstructionContext.
Removes methods which are based on index_in_instruction.

* Adjusts program-runtime.

* Adjusts runtime.

* Adjusts bpf loader.

* Adjusts built-in programs.

* Adjusts program-test and bpf tests.
2022-06-16 18:46:17 +02:00
bji cbb0f07d54
Award one credit per dequeued vote when processing VoteStateUpdate in… (#25743)
* Award one credit per dequeued vote when processing VoteStateUpdate instruction,
to match vote rewards of Vote instruction.

* Update feature pubkey to one owned by cc (ashwin)

Co-authored-by: Ashwin Sekar <ashwin@solana.com>
2022-06-06 16:37:03 -07:00
Brooks Prumo 0b2d5291f8
Add new error if stake delegation is below the minimum (#25709) 2022-06-01 20:29:57 -05: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
Justin Starry 2ad1baa753
Add const fn StakeState::size_of and static assertion (#24416) 2022-04-20 01:04:12 +08:00
Brooks Prumo f33ad34531
Add feature_set_override parameter to mock_process_instruction() (#24386) 2022-04-15 13:43:04 -05:00
Brooks Prumo 34418cb848
Stake tests use get_minimum_delegation() (#24382) 2022-04-15 18:30:45 +00:00
Brooks Prumo 7cf80a3f62
Fix test to use correct/updated account in transaction (#24363) 2022-04-15 05:15:02 -05:00
Michael Vines 57ff7371b4 Add StakeInstruction::DeactivateDelinquent 2022-04-14 01:49:22 -04:00
Brooks Prumo f7b00ada1b
GetMinimumDelegation does not require a stake account (#24192) 2022-04-11 16:26:36 -05: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 cb1507126f
Fixes check_number_of_instruction_accounts() in StakeInstruction::Authorize. (#24172) 2022-04-08 12:43:55 +02:00
Brooks Prumo a100b32b37
Add test for GetMinimumDelegation stake instruction (#24158) 2022-04-07 11:54:15 -05: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
Alexander Meißner 1b45c509c3
Refactor: Use `InstructionContext::get_instruction_data()` (#24014)
* Adds transaction_context and instruction_context where invoke_context.get_keyed_accounts() is used.

* Use instruction_context.get_instruction_data() instead of an explicit parameter.

* Removes instruction_data parameter from Executor::execute().

* Removes instruction_data parameter from ProcessInstructionWithContext.
2022-04-01 15:48:05 +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
Alexander Meißner 794645d092
Adds check_number_of_instruction_accounts() to all builtin programs except for the address-lookup-table. (#23984) 2022-03-29 19:06:50 +02:00
Alexander Meißner 140c8dd01f
Refactor: Replaces KeyedAccount in_get_sysvar_with_account_check (#23905)
* Replaces all use sites of get_sysvar_with_account_check by get_sysvar_with_account_check2.

* Removes get_sysvar_with_account_check.

* Renames get_sysvar_with_account_check2 to get_sysvar_with_account_check.
2022-03-24 19:30:42 +01:00
Alexander Meißner 91c2729856
Replaces keyed_account get_signers() by InstructionContext::get_signers(). (#23863) 2022-03-24 12:57:51 +01:00
Brooks Prumo 18bddbc730
Stake tests respect MINIMUM_STAKE_DELEGATION (#23426) 2022-03-16 16:36:23 -05:00
Alexander Meißner 584ac80b1e
Revert: `KeyedAccount` refactoings in builtin programs (#23649)
* Revert "Replaces KeyedAccount by BorrowedAccount in the BPF loader. (#23056)"

6c56eb9663

* Revert "Replaces `KeyedAccount` by `BorrowedAccount` in `system_instruction_processor`. (#23217)"

ee7e411d68

* Revert "Replaces `KeyedAccount` by `BorrowedAccount` in `nonce_keyed_account`. (#23214)"

1a68f81f89

* Revert "Replaces KeyedAccount by BorrowedAccount in the config processor. (#23302)"

a14c7c37ee

* Revert "Replaces `KeyedAccount` by `BorrowedAccount` in vote processor (#23348)"

e2fa6a0f7a

* Revert "Refactor: Prepare stake_instruction.rs to remove `KeyedAccount`s (#23375)"

ee3fc39f1c
2022-03-16 11:30:01 +01:00