Commit Graph

3262 Commits

Author SHA1 Message Date
carllin de1d7ce312
Cleanup staking utils to divide functionality between delegate and normal node utitliites. Also replaces vote_states() with more generalized vote_accounts() in Bank. (#3070) 2019-03-03 18:04:13 -08:00
Rob Walker e4dba03e12
accounts shedding (#3078)
* accounts shedding

* fixup
2019-03-03 16:04:04 -08:00
Greg Fitzgerald fc5fcd6cd4 Move native_loader into solana_runtime 2019-03-03 10:59:08 -07:00
Greg Fitzgerald 41b5899856 Move programs/Cargo.toml into bpf/ 2019-03-02 22:11:48 -08:00
Greg Fitzgerald b830449f23 Move top-level native program tests to their respective crates 2019-03-02 22:11:48 -08:00
Greg Fitzgerald 037fcf6b3d Bump all native programs up a level
Don't categorize programs by a single backend.
2019-03-02 22:11:48 -08:00
Stephen Akridge e1a1296b9b Fix cleanup_paths
Add back remove of parent in Accounts::drop, but
remove that in the cleanup_paths helper
for the account tests which do not use
make_default_dir.
2019-03-02 20:24:57 -08:00
Michael Vines a9a7fc56eb Purge MAX_RECENT_TICK_HASHES 2019-03-02 17:04:42 -08:00
Greg Fitzgerald 1edf6c361e
Move Vote program out of the SDK 2019-03-02 16:44:36 -08:00
Sagar Dhawan b99e3eafdd
Fix stakes not being setup correctly 2019-03-02 16:44:36 -08:00
Greg Fitzgerald e6486b2824
Move Budget out of the SDK 2019-03-02 16:44:36 -08:00
Sagar Dhawan d22a13257e
Refactor bank get vote accounts (#3052) 2019-03-02 16:44:36 -08:00
Rob Walker f4c5b9ccb0 remove remove_dir_all() of paths' parents (which we didn't make to begin with) 2019-03-02 12:36:41 -08:00
Michael Vines a94880574b block_hash => blockhash 2019-03-02 12:13:30 -07:00
Michael Vines 0f1582c196 cargo fmt 2019-03-02 12:13:30 -07:00
Michael Vines 258cf21416 Purge remaining last_id (now called block_hash) 2019-03-02 12:13:30 -07:00
Michael Vines 2bfad87a5f Rename Bank.last_id() to Bank.last_block_hash() 2019-03-02 12:13:30 -07:00
Michael Vines 0743f54dfe Rename LastIdNotFound to BlockHashNotFound 2019-03-02 12:13:30 -07:00
Michael Vines 176d5e0d37 Rename Transaction last_id field to recent_block_hash 2019-03-02 12:13:30 -07:00
Stephen Akridge 16b71a6be0 Cleanup fork id generation
Accounts could end up with id collision depending on how
banks are created, this shouldn't happen.
2019-03-02 10:34:41 -08:00
Michael Vines d5de5bec4f Register a new last_id once per slot 2019-03-02 08:47:31 -08:00
Michael Vines 61beb42797 Decouple tick counting from hash queue 2019-03-02 08:47:31 -08:00
Michael Vines e5be3e1dca HashQueue no longer hard codes max_entries 2019-03-02 08:47:31 -08:00
Greg Fitzgerald 49b7e67585 Return program error from process_transaction()
Our unit-test helper `process_transaction()` wasn't returning
program errors, which made testing programs tedious and
counter-intuitive.
2019-03-02 07:50:32 -07:00
Rob Walker 54417acfba
changed vote_states to vote_accounts, more useable (#3047) 2019-03-01 17:22:49 -08:00
Rob Walker 29d12d9ff1
remove new_bank_from_parent_with_id() (#3039) 2019-03-01 16:39:23 -08:00
Stephen Akridge 4ee857ab7d More vote account fixes
vote_index not being maintained correctly during a squash.
The tokens==0 shielding accounts were being inserted with
owner=default Pubkey so they didn't know they are vote accounts
and should update the vote accounts set.
2019-03-01 16:25:14 -08:00
Rob Walker a7c18cc0b4 Fnbool_to_FnOptionT 2019-03-01 14:12:50 -08:00
Michael Vines e30e4cc603 Remove get_confirmation_timestamp() from HashQueue 2019-03-01 13:38:17 -08:00
Michael Vines fdc31e99df Clean up type casts 2019-03-01 13:38:17 -08:00
Michael Vines a72325dbc2 entry_id -> entry 2019-03-01 13:38:17 -08:00
Michael Vines 67b6be66c8 Rename MAX_ENTRY_IDS 2019-03-01 13:38:17 -08:00
Michael Vines 8ec13d557f Generalize tick_height to hash_height 2019-03-01 13:38:17 -08:00
Michael Vines 31f570a9f4 Remove unused functions 2019-03-01 13:38:17 -08:00
Rob Walker 38273427ad
have banks save vote_state by epoch to support stable leader schedules (#3019)
have banks save vote_state by epoch to support stable leader schedules
2019-03-01 11:54:28 -08:00
Michael Vines 46fb0b1b94 Rename last_id to last_hash within HashQueue 2019-03-01 11:48:09 -08:00
Michael Vines 224b705f8d Rename genesis_block.last_id() to genesis_block.hash() 2019-03-01 11:48:09 -08:00
Michael Vines a57fb00584 Rename last_id_queue.rs to hash_queue.rs 2019-03-01 09:50:51 -08:00
Michael Vines 360055ad70 Rename LastIdQueue to HashQueue 2019-03-01 09:50:51 -08:00
Greg Fitzgerald c53c351759 Rename erc20 to token-program
Everything it uses already had that name, just the crate was never
renamed.
2019-03-01 10:47:38 -07:00
Pankaj Garg b41286919d
Rename bank.id to bank.slot (#3018) 2019-02-28 18:02:45 -08:00
Sagar Dhawan 20e4edec61
Refactor Vote Program Account setup (#2992) 2019-02-28 17:08:45 -08:00
Stephen Akridge 1c44b738fe Fix vote_accounts test 2019-02-28 15:22:47 -08:00
carllin 217f30f9c3
Add get_supermajority_slot() function (#2976)
* Moved supermajority functions into new module, staking_utils

* Move staking functions out of bank, and into staking_utils, change get_supermajority_slot to only use state from epoch boundary

* Move bank slot height in staked_nodes_at_slot() to be bank id
2019-02-28 13:15:25 -08:00
Sathish Ambley 0f2226901d Fix transaction count after squash 2019-02-27 23:21:49 -08:00
Michael Vines dad1511484 test_bank_squash: validate transaction_count() before/after squashing 2019-02-27 23:21:49 -08:00
Rob Walker d23f8a3e99
increase accounts coverage (#2993) 2019-02-27 21:42:14 -08:00
Michael Vines 0dc5af62ff Standardize on 'use log::*' for easy access to all log level macros 2019-02-27 21:16:23 -08:00
Michael Vines 855f1823a4 Include solana-logger for use by tests 2019-02-27 21:16:23 -08:00
Rob Walker 7fd40f1eb9
add failing test for #2994 (#2995) 2019-02-27 20:46:26 -08:00
Stephen Akridge 95f2f05f45 Refactor account serialize in appendvec
Remove dupe code and see how this compares to bincode.
Add benchmarks to justify custom serialize and also experiment with
safe solutions.
2019-02-27 19:57:50 -08:00
Rob Walker 163874d4da
remove `purge` parameter to accounts (#2990) 2019-02-27 16:06:06 -08:00
Michael Vines b6ccb475f1
Clarify FIXME source 2019-02-27 10:37:48 -08:00
Sathish Ambley ca0f16ccc0 Fix test failure 2019-02-27 08:22:52 -08:00
Stephen Akridge c241a56fb0 Remove extraneous print. 2019-02-27 08:22:52 -08:00
Sathish Ambley 4149f7fd1c Fix review comments 2019-02-27 08:22:52 -08:00
Sathish Ambley 96b349dcbb Performance optimizations 2019-02-27 08:22:52 -08:00
Stephen Akridge 5216952691 Change benchmark path to target/ or OUT_DIR
Also reduce some code duplication with cleanup_dirs fn.
2019-02-27 08:22:52 -08:00
Sathish Ambley c46b2541fe - Fix lock/unlock of accounts
- Fix format check warnings
2019-02-27 08:22:52 -08:00
Stephen Akridge 2158ba5863 tx count per fork 2019-02-27 08:22:52 -08:00
Stephen Akridge 180d297df8 Rebase and panic with no accounts
Add Accounts::has_accounts function for hash_internal_state calculation.
2019-02-27 08:22:52 -08:00
Sathish Ambley c276375a0e Persistent account storage across directories 2019-02-27 08:22:52 -08:00
Sathish Ambley 130563cd4c AppendVec 2019-02-27 08:22:52 -08:00
carllin 033a04129a Add lockouts to vote program (#2944)
* Add lockouts to vote program

* Rename MAX_VOTE_HISTORY TO MAX_LOCKOUT_HISTORY, change process_vote() to only pop votes after MAX_LOCKOUT_HISTORY + 1 votes have arrived

* Correctly calculate serialized size of an Option, rename root_block to root_slot
2019-02-26 22:19:31 -07:00
Stephen Akridge 72214b2b68 Squash test to test parent bank after squash 2019-02-26 15:15:34 -08:00
Rob Walker 87281f6ed5
ensure at Accounts level that tokens == 0 means None (#2960) 2019-02-26 13:51:39 -08:00
Greg Fitzgerald af206111e2 Hoist new leader scheduler up to protocol level
Attempt to feel similar to LeaderScheduler to easy migration.
2019-02-26 08:23:01 -08:00
Greg Fitzgerald 3897b66270 Let the bank creator decide where to send transaction fees 2019-02-26 08:06:08 -07:00
Greg Fitzgerald feefdca969 Minor cleanup to Bank and LastIdQueue 2019-02-26 06:46:38 -08:00
Rob Walker 25690ff078
merge_parents() => squash() (#2943) 2019-02-25 20:34:05 -08:00
Michael Vines 897279eddb Encapsulate log::Level so counter macro users don't need to use it 2019-02-25 20:01:30 -08:00
Rob Walker 67c9bbc6b2
* drop parents once merged (#2930)
* add bank.id() which can be used by BankForks, blocktree_processor
* add bank.hash(), make hash_internal_state() private
* add bank.freeze()/is_frozen(), also useful for blocktree_processor, eventual freeze()ing in replay
2019-02-25 14:05:02 -08:00
Greg Fitzgerald 2fbdec59cb Generalize access to staked nodes 2019-02-25 08:49:43 -08:00
Greg Fitzgerald 710f88edda Handle edge cases earlier
We have lots of tests that work off genesis block.  Also, one
might want to generate a future leader schedule under the assumption
the stakers stay the same.
2019-02-25 08:49:43 -08:00
Greg Fitzgerald db899a2813 Inline LeaderSchedule::new_from_bank()
Breaks circular dependency and offers more flexibility in bank's
usage.
2019-02-25 08:49:43 -08:00
Greg Fitzgerald aad0d90fdd Use epoch_height to generate schedule instead of last_id
I had suggested the last_id, but that puts an unnecessary dependency
on LastIdsQueue. Using epoch height is pretty interesting in that
given the same set of stakers, you simply increment the seed once
per epoch.

Also, tighten up the LeaderSchedule code.
2019-02-25 08:49:43 -08:00
Greg Fitzgerald 72b4834446 Add Bank::prev_slot_leader() and Bank::next_slot_leader() 2019-02-25 08:49:43 -08:00
Greg Fitzgerald ec48c58df1 Award tx fees to validators in new leader schedule
Also, generalize the leader_schedule functions a bit to allow for
prev_slot_leader and next_slot_leader, should they be needed.
2019-02-25 08:49:43 -08:00
Greg Fitzgerald 0947ec59c9 Expose the new leader schedule functionality from the bank. 2019-02-25 08:49:43 -08:00
Greg Fitzgerald ba7d121724 Switch to Bank::staked_nodes(); want node_id, not staker_id
Also, update LeaderScheduler's code to use node_id as well.
Unfortuntely, no unit tests for this, because there's currently
only one way to set staker_id/node_id, and they are both set
to the same value.
2019-02-24 07:52:44 -07:00
Greg Fitzgerald a1070e9572 Split ActiveStakers over Bank and LeaderScheduler 2019-02-24 07:52:44 -07:00
Stephen Akridge 66891d9d4e Don't use global storage account
Other accounts would not be able to modify the system accounts userdata.
2019-02-22 15:59:55 -08:00
Greg Fitzgerald 11c7aab023 Add some unit-tests 2019-02-22 16:18:10 -07:00
Greg Fitzgerald 5541eedcc4 Reject modifications to userdata if not owned by the program 2019-02-22 16:18:10 -07:00
Pankaj Garg c07b6c30a1 Remove special casing of ProgramError in blocktree processor
- Also refactor bank.rs and add unit tests
2019-02-22 12:13:05 -08:00
Greg Fitzgerald f0f55af35b Add scheduler config to genesis
Anything that affects how the ledger is interpreted needs to be
in the genesis block or someplace on the ledger before later
parts of the ledger are interpreted. We currently don't have an
on-chain program for cluster parameters, so that leaves only
the genesis block option.
2019-02-21 17:29:55 -08:00
Pankaj Garg 3e8d96a95b fix failing tests 2019-02-21 16:35:23 -08:00
Pankaj Garg 9713a3ac02 fix clippy warnings 2019-02-21 16:35:23 -08:00
Pankaj Garg 5c9777970d moved fee collection code to runtime 2019-02-21 16:35:23 -08:00
Pankaj Garg c142a82ae0 Charge transaction fee even in case of ProgramError 2019-02-21 16:35:23 -08:00
Greg Fitzgerald f76ac94d70 Remove leader_schedule_offset public method
Also,

* Rename the private variable to include units.
* Better doc
2019-02-21 12:28:11 -08:00
Greg Fitzgerald 32caa55d67 Offer a way to get the leader_schedule from any Bank instance 2019-02-21 12:28:11 -08:00
Rob Walker f6ff33db8e
* add merge_parents(), which means 'eat your parent' (#2851)
* add is_root(), which is false if the bank has a parent
* use is_root() for store_slow and store_accounts to decide whether to purge on zero balance
2019-02-21 12:08:50 -08:00
Greg Fitzgerald 40977fa99f More forward-looking test 2019-02-21 10:54:25 -07:00
Greg Fitzgerald f4df8ff5b3 Add slot_height() and epoch_height() methods to Bank 2019-02-21 10:54:25 -07:00
Sagar Dhawan 13d018e3e1
Fix stake selection for the Data Plane (#2863)
* Update data-plane to use stakes instead of a bank directly

* Rename get_stakes to staked_nodes
2019-02-20 21:38:16 -08:00
Sagar Dhawan 3c62e2332e
Cleanup stakes for gossip (#2860) 2019-02-20 20:02:47 -08:00
Greg Fitzgerald b8f6280fe5 Move hash_internal_state tests into runtime
This was intended as a Bank test, but only in blocktree_processor
because of its dependency on Entry, which solana_runtime doesn't
know about.
2019-02-20 16:13:26 -08:00
Greg Fitzgerald 822bebea46 Allow multiple forks without regenerating the hash 2019-02-20 16:13:26 -08:00
Greg Fitzgerald 582a7192ec Hold Bank's own parent hash instead of the parent's 2019-02-20 16:13:26 -08:00
Greg Fitzgerald 9848de6cda Remove special case in Bank::deposit()
And use it to process the genesis block.
2019-02-20 08:12:37 -07:00
Pankaj Garg a33921ed34 address review comments 2019-02-20 08:12:37 -07:00
Pankaj Garg 2e75ff27ac Fix test 2019-02-20 08:12:37 -07:00
Pankaj Garg a27cdf55e7 Credit transaction fees to the slot leader 2019-02-20 08:12:37 -07:00
Greg Fitzgerald dda0a1f39b Move storage tests out of Bank 2019-02-19 17:26:33 -07:00
Greg Fitzgerald 04f54655c2 Minor cleanup 2019-02-19 15:53:31 -08:00
Rob Walker dc5590f2bf
unuse std (#2833) 2019-02-19 15:27:07 -08:00
Greg Fitzgerald 64dcc31ac7 Migrate Rewards test from runtime to Bank 2019-02-19 10:59:06 -07:00
Greg Fitzgerald 36546b4c4c Expose a Bank API for adding native programs
Also use it to tighten up the code to add the builtin programs.
2019-02-19 10:20:27 -07:00
Greg Fitzgerald dde886f058 Move Bank to its own crate
Also:
* counters.rs to solana_metrics
* genesis_block.rs to solana_sdk
2019-02-19 07:17:04 -07:00
Greg Fitzgerald cdb2a7bef3 Move runtime benchmark 2019-02-07 09:46:06 -08:00
Greg Fitzgerald 5128d7d6c3 Move runtime.rs into its own crate 2019-02-07 09:46:06 -08:00