Commit Graph

81 Commits

Author SHA1 Message Date
Trent Nelson c4e43f1de4
vote: encapsulate `Lockout` (#29753) 2023-01-18 19:28:28 -07:00
Jon Cinque 968b158494
vote: Prevent commission update in the second half of epochs (#29362)
* vote: Prevent commission update in the second half of epochs

* Address feedback

* Fix tests

* Make the feature enabled by single-contributor

* Use a cooler pubkey
2022-12-23 12:24:39 +01:00
Brooks Prumo d1ba42180d
clippy for rust 1.65.0 (#28765) 2022-11-09 19:39:38 +00:00
Ashwin Sekar 9eafad467c
Add convenience methods to VoteInstruction to distinguish vote types (#28526)
* Add convenience methods to VoteInstruction to distinguish vote types

* use matches! macro instead
2022-10-21 14:17:40 -06:00
Ashwin Sekar c74df830b1
Add structure to collect and coalesce vote packets (#27558)
* Add structure to collect and coalesce vote packets

Will be used in banking stage to throw out extraneous vote packets
before processing

* pr comments

* Update inner lock to arc to improve performance
2022-09-14 00:44:26 -07:00
royalrust 0cff1eff08
move if let destructuring out of for loop (#27712)
* move if let destructuring out of for loop

* remove trailing whitespace

* Update programs/vote/src/vote_state/mod.rs

Co-authored-by: Justin Starry <justin.m.starry@gmail.com>
2022-09-12 18:08:02 +00:00
behzad nouri 4f22ee8f9b uses varint encoding for vote-state lockout offsets
The commit removes CompactVoteStateUpdate and instead reduces serialized
size of VoteStateUpdate using varint encoding for vote-state lockout
offsets.
2022-09-12 16:31:20 +00:00
Alexander Meißner 12d2147efa
Adds `IndexOfAccount` type (#27599)
Adds the type `IndexOfAccount`.
2022-09-06 11:31:40 +02:00
carllin ad6c2d8c5f
Handle VoteStateUpdates for outdated roots bigger than slots in existing VoteState (#27323)
* Set root to latest vote in tower <= prposed vote state

* fixup tests

* PR comments

* feature gate
2022-08-24 20:42:57 -05:00
Ashwin Sekar efa6201eda
Check overflow on vote tx compaction boundary (#27185)
* Check overflow on vote tx compaction boundary

Check for overflow during the conversion between VoteStateUpdate and
CompactVoteStateUpdate.

* Try removing clippy supress
2022-08-23 22:29:03 -07:00
Michael Vines ccfbc54195 Move vote program state and instructions to solana-program 2022-08-09 20:52:47 -07:00
Justin Starry dcfd823ca8
Clean up activated `reject_non_rent_exempt_vote_withdraws` feature (#26558)
Clean up activated reject_non_rent_exempt_vote_withdraws feature
2022-07-12 18:17:42 +01:00
Ashwin Sekar 734fedea4c
Create a more compact vote state update transaction (#26092)
* Create a more compact vote state update transaction

* pr comments

* change root to not be an option and update abi
2022-07-07 22:29:02 -07:00
Justin Starry fa77cc5e48
Fix active vote account close error (#26250) 2022-06-28 20:35:23 +01: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
Steven Luscher 45d11f3d26
Implement `VoteInstruction::AuthorizeWithSeed` & `VoteInstruction::AuthorizeWithSeedChecked` (#25928)
* [vote_authorize_with_seed] Add `VoteInstruction::AuthorizeWithSeed`

* [vote_authorize_with_seed] You can now update a vote account's authority if it's a derived key for which you control the base key

* [vote_authorize_with_seed] Add test helper to create a vote account whose authorities are derived keys

* [vote_authorize_with_seed] Write tests to assert the behavior of `VoteInstruction::AuthorizeWithSeed`

* [vote_authorize_with_seed] Feature gate the `VoteInstruction::AuthorizeWithSeed` processor

* [vote_authorize_with_seed] Add `VoteInstruction::AuthorizeWithSeed` to transaction status parser

* [vote_authorize_with_seed] Add `VoteInstruction::AuthorizeWithSeed` to docs

* [vote_authorize_with_seed] Add `VoteInstruction::AuthorizeCheckedWithSeed`

* [vote_authorize_with_seed] You can now update a vote account's authority (while checking that the new authority has signed) if it's a derived
key for which you control the base key

* [vote_authorize_with_seed] Add `VoteInstruction::AuthorizeCheckedWithSeed` to transaction status parser

* [vote_authorize_with_seed] Write tests to assert the behavior of `VoteInstruction::AuthorizeCheckedWithSeed`
2022-06-13 20:36:44 -07: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
Will Hickey 88299e72b8
Add metrics to vote account close feature (#25746) 2022-06-03 11:27:46 -05:00
Michael Vines b05c7d91ed Fix derive_partial_eq_without_eq clippy lint 2022-05-22 22:22:21 -07:00
behzad nouri 16222553b8
defines const fn for serialized size of VoteState, Feature and Nonce (#24435)
bincode::serialized_sized requires constructing a temporary object and
it is slow. Silently changing serialized size of these structs can also
be a backward incompatible change.
This commit instead hard-codes serialized size of VoteState, Feature and
Nonce, and defines the functions as const. Added tests verify hard-coded
values.
2022-04-19 13:10:14 +00:00
Michael Vines 57ff7371b4 Add StakeInstruction::DeactivateDelinquent 2022-04-14 01:49:22 -04:00
Alexander Meißner 2e5042d8bd
Remove `KeyedAccount` in builtin program "vote" (#24189)
* Uses transaction_context.get_key_of_account_at_index() in vote.

* Inline keyed_account_at_index() in all instructions of vote
which have more than one KeyedAccount parameter,
because these could cause a borrow collision.

* Replaces KeyedAccount by BorrowedAccount in vote.
2022-04-08 20:40:50 +02: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
SAITO Kosuke | Coinfra NFT Creator a57c7ba5df
Change comments (#23366)
* change url

* change comment

Co-authored-by: cosuke2000 <saitou@matchingood.co.jp>
2022-02-27 10:36:25 -07:00
Alexander Meißner e2fa6a0f7a
Replaces `KeyedAccount` by `BorrowedAccount` in vote processor (#23348)
* Use instruction_account_indices, get_sysvar_with_account_check2 and instruction_context.get_signers in vote processor.

* Replaces KeyedAccount by BorrowedAccount in vote processor.

* Removes KeyedAccount from benches in vote processor.
2022-02-25 17:22:54 +01:00
Alexander Meißner 804fac8ea9
Removes KeyedAccount from tests in vote processor. (#23333) 2022-02-25 08:21:28 +01:00
Ashwin Sekar 6ae87109d2
Improve performance of root slot in slot hashes history check (#22990)
* Fold the root slot check into loop for performance

* Add assert in case vote state root is not older than slot hashes
2022-02-15 20:17:56 -07:00
Ashwin Sekar 5acf0f6331
Add feature gate for new vote instruction and plumb through replay (#21683)
* Add feature gate for new vote instruction and plumb through replay

Add tower versions

* Add check for slot hashes history

* Update is_recent check to exclude voting on hard fork root slot

* Move tower rollback test to flaky and ignore it until #22551 lands
2022-02-07 14:06:19 -08:00
Will Hickey 75563f6c7b
Reject close of active vote accounts (#22651)
* 10461 Reject close of vote accounts unless it earned no credits in the previous epoch. This is checked by comparing current epoch (from clock sysvar) with the most recent epoch with credits in vote state.
2022-02-02 14:16:24 -06:00
carllin 1cf6c97779
Add checks to vote state updates to handle updates outside of SlotHash history (#22358) 2022-01-25 13:47:31 -05:00
Justin Starry 7f20c6149e
Refactor: move simple vote parsing to runtime (#22537) 2022-01-20 10:39:21 +08:00
Michael Vines 65f1e0fcc2 vote account withdraw authority may change the authorized voter 2022-01-15 21:47:08 -08:00
Justin Starry ae6c511f13
Refactor: Split vote_instruction.rs into multiple files (#22502) 2022-01-14 17:25:15 +08:00
carllin 4ab7d6c23e
Filter out outdated slots (#22450)
* Filter out outdated slots

* Fixup error
2022-01-13 19:51:00 -05:00
Justin Starry 2370e61431
Perf: Store deserialized sysvars in the sysvars cache (#22455)
* Perf: Store deserialized sysvars in sysvars cache

* add bench
2022-01-13 05:36:21 +00:00
behzad nouri 4d62f03297
uses enum instead of trait for VoteTransaction (#22019)
Box<dyn Trait> involves runtime dispatch, has significant overhead and
is slow. It also requires hacky boilerplate code for implementing Clone
or other basic traits:
https://github.com/solana-labs/solana/blob/e92a81b74/programs/vote/src/vote_state/mod.rs#L70-L102

Only limited known types can be VoteTransaction and they are all defined
in the same crate. So using a trait here only adds overhead.
https://github.com/solana-labs/solana/blob/e92a81b74/programs/vote/src/vote_state/mod.rs#L125-L165
https://github.com/solana-labs/solana/blob/e92a81b74/programs/vote/src/vote_state/mod.rs#L221-L264
2021-12-22 14:25:46 +00:00
Ashwin Sekar 4bc5bfb2df
Addressing leftover comments from #21531 (#21782)
* Addressing leftover comments from #21531

* Add feature flag

* Feature gate new vote instruction

* add clock & slot hashes sysvar to test
2021-12-13 07:52:22 -08:00
Ashwin Sekar f0acf7681e
Add vote instructions that directly update on chain vote state (#21531)
* Add vote state instructions

UpdateVoteState and UpdateVoteStateSwitch

* cargo tree

* extract vote state version conversion to common fn
2021-12-07 16:47:26 -08:00
Justin Starry e123883b26
Reject vote withdraws that create non-rent-exempt accounts (#21639)
* Reject vote withdraws that create non-rent-exempt accounts

* fix mocked instruction test
2021-12-06 17:01:20 -05:00
carllin a433bb310d
Add ability to update entire vote state (#20014) 2021-12-03 16:01:21 -05: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
Justin Starry ef29d2d172
Refactor vote state to remove double negative (#21244) 2021-11-12 00:26:43 +00:00
Justin Starry db9336c99e
Remove feature switch handling for checking vote init (#20557) 2021-10-08 23:35:26 -04:00
Michael Vines 7027d56064 Resolve nightly-2021-10-05 clippy complaints 2021-10-06 10:37:58 -07:00
Alexander Meißner 6514096a67 chore: cargo +nightly clippy --fix -Z unstable-options 2021-06-18 10:42:46 -07:00
Justin Starry 8e561354d5
Improve readability of vote lockout processing (#16987)
* Improve readability of vote lockout processing

* clippy

* simplify comment

* feedback
2021-05-02 08:36:06 +00:00
Jeff Washington (jwash) 5e74cede4e
lamports -> lamports() (#16979) 2021-04-30 21:03:08 +00:00
Jeff Washington (jwash) 6f88aeac56
tests: .lamports= -> .set_lamports() (#16977)
* .lamports= -> .set_lamports()

* another

* fix

* another
2021-04-30 18:44:15 +00:00
Jeff Washington (jwash) 8dc15f727c
account.lamports -= (#16913) 2021-04-28 15:47:59 -05:00
Jeff Washington (jwash) 3887169db0
lamports += to checked_add (#16841) 2021-04-27 09:56:18 -05:00