Commit Graph

63 Commits

Author SHA1 Message Date
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
Alexander Meißner 9dfcb921cf
Refactoring: Move KeyedAccounts to InvokeContext (#15410)
Collects all parametric occurrences and the construction of keyed_accounts and puts them into InvokeContext.
2021-04-19 18:48:48 +02:00
carllin dc7030ffaa
Allow fork choice to support multiple versions of a slot (#16266) 2021-04-12 01:00:59 -07:00
Jeff Washington (jwash) 8a3135d17b
Account->AccountSharedData (#15691) 2021-03-09 15:06:07 -06:00
Tyera Eulberg eddb7f98f5
Check vote account initialization (#15503)
* Check account data_len on Vote account init

* Check account data populated on update_cached_accounts
2021-02-24 10:00:48 -07:00
Stephen Akridge f929301c60 Vote program updates 2021-02-16 18:59:15 -08:00
Ryo Onodera ab0f4c69aa
Improve vote-account for logical flow/reasoning (#15237)
* Improve vote-account for logical flow/reasoning

* Clean up

* Update messages
2021-02-11 21:24:20 +09:00
behzad nouri 8e581601d6
patches crds vote-index assignment bug (#14438)
If tower is full, old votes are evicted from the front of the deque:
https://github.com/solana-labs/solana/blob/2074e407c/programs/vote/src/vote_state/mod.rs#L367-L373
whereas recent votes if expire are evicted from the back:
https://github.com/solana-labs/solana/blob/2074e407c/programs/vote/src/vote_state/mod.rs#L529-L537

As a result, from a single tower_index scalar, we cannot infer which crds-vote
should be overwritten:
https://github.com/solana-labs/solana/blob/2074e407c/core/src/crds_value.rs#L576

In addition there is an off by one bug in the existing code. tower_index is
bounded by MAX_LOCKOUT_HISTORY - 1:
https://github.com/solana-labs/solana/blob/2074e407c/core/src/consensus.rs#L382
So, it is at most 30, whereas MAX_VOTES is 32:
https://github.com/solana-labs/solana/blob/2074e407c/core/src/crds_value.rs#L29
Which means that this branch is never taken:
https://github.com/solana-labs/solana/blob/2074e407c/core/src/crds_value.rs#L590-L593
so crds table alwasys keeps 29 **oldest** votes by wallclock, and then
only overrides the 30st one each time. (i.e a tally of only two most
recent votes).
2021-01-21 13:08:07 +00:00
Trent Nelson db5bd6ea1a Deinitialize vote data upon zero balance 2020-12-22 19:37:26 -07:00
Trent Nelson 5b903318b2 vote: Add helper for creating current-versioned states 2020-12-22 19:37:26 -07:00
Michael Vines 7143aaa89b Clippy 2020-12-14 08:03:29 -08:00
sakridge 2cb006fa44
Use info for failed to match slot vote error (#13715) 2020-11-19 16:01:37 -08:00
Ryo Onodera 0e4509c497
Small code cleanup and typo fixes (#13325)
* Small code cleanup and typo fixes

* Clean up calculate_points_and_credits
2020-11-02 10:28:24 +09:00
Michael Vines 1b343665a1 Move KeyedAccount out of solana-program. Native programs are not supported by solana-program 2020-10-26 18:54:54 -07:00
Michael Vines a4956844bd Update frozen_abi hashes
The movement of files in sdk/ caused ABI hashes to change
2020-10-24 08:37:55 -07:00
Michael Vines 7bc073defe Run `codemod --extensions rs Pubkey::new_rand solana_sdk::pubkey::new_rand` 2020-10-21 19:08:13 -07:00
Ryo Onodera cb8661bd49
Persistent tower (#10718)
* Save/restore Tower

* Avoid unwrap()

* Rebase cleanups

* Forcibly pass test

* Correct reconcilation of votes after validator resume

* d b g

* Add more tests

* fsync and fix test

* Add test

* Fix fmt

* Debug

* Fix tests...

* save

* Clarify error message and code cleaning around it

* Move most of code out of tower save hot codepath

* Proper comment for the lack of fsync on tower

* Clean up

* Clean up

* Simpler type alias

* Manage tower-restored ancestor slots without banks

* Add comment

* Extract long code blocks...

* Add comment

* Simplify returned tuple...

* Tweak too aggresive log

* Fix typo...

* Add test

* Update comment

* Improve test to require non-empty stray restored slots

* Measure tower save and dump all tower contents

* Log adjust and add threshold related assertions

* cleanup adjust

* Properly lower stray restored slots priority...

* Rust fmt

* Fix test....

* Clarify comments a bit and add TowerError::TooNew

* Further clean-up arround TowerError

* Truly create ancestors by excluding last vote slot

* Add comment for stray_restored_slots

* Add comment for stray_restored_slots

* Use BTreeSet

* Consider root_slot into post-replay adjustment

* Tweak logging

* Add test for stray_restored_ancestors

* Reorder some code

* Better names for unit tests

* Add frozen_abi to SavedTower

* Fold long lines

* Tweak stray ancestors and too old slot history

* Re-adjust error conditon of too old slot history

* Test normal ancestors is checked before stray ones

* Fix conflict, update tests, adjust behavior a bit

* Fix test

* Address review comments

* Last touch!

* Immediately after creating cleaning pr

* Revert stray slots

* Revert comment...

* Report error as metrics

* Revert not to panic! and ignore unfixable test...

* Normalize lockouts.root_slot more strictly

* Add comments for panic! and more assertions

* Proper initialize root without vote account

* Clarify code and comments based on review feedback

* Fix rebase

* Further simplify based on assured tower root

* Reorder code for more readability

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-09-19 14:03:54 +09:00
Michael Vines 247f27af37
Submit a vote timestamp every vote (#10630)
* Submit a timestamp for every vote

* Submit at most one vote timestamp per second

* Submit a timestamp for every new vote

Co-authored-by: Tyera Eulberg <tyera@solana.com>
2020-08-21 11:10:51 -06:00
Tyera Eulberg b1bc901a66
Allow votes to timestamp subsequent slots with the same timestamp (#11715) 2020-08-19 23:19:24 +00:00