Commit Graph

1430 Commits

Author SHA1 Message Date
Gavin Chan 20d031e2b8
Refactor ExecuteTimings w/ enum-indexed array (#23085) 2022-02-22 14:46:56 -08:00
Justin Starry bcda74f42f
Fix builtin handling on epoch boundaries (#23256) 2022-02-22 20:54:08 +08:00
Tyera Eulberg 7e08ae1d0c
Revert "Add simulation detection countermeasure (#22880)" (#23261)
This reverts commit c42b80f099.
2022-02-21 21:15:37 +00:00
buffalu 70ebab2c82
Add rustfmt.toml and `cargo fmt` (#23238)
* fmt

* formatted

Co-authored-by: Lucas B <buffalu@jito.network>
2022-02-19 13:32:29 +08:00
Justin Starry 1719d2349f
Skip adding builtins if they will be removed (#23233)
* Add failing test for precompile transition

* Skip adding builtins if they will be removed

* cargo clean

* nits

* fix abi check

* remove workaround

Co-authored-by: Jack May <jack@solana.com>
2022-02-18 18:36:59 -08:00
Jack May 970f543ef6
Precompiles owned by the native loader (#23237) 2022-02-18 15:41:59 -08:00
Alexander Meißner da00b39f4f
Cleanup: get_program_key() and get_loader_key() in TransactionContext (#23191)
* Moves TransactionContext::get_program_key() to InstructionContext::get_program_key().

* Removes TransactionContext::get_loader_key().

* Test full program and loader executable account chain in BPF loader.
2022-02-17 10:16:28 +01:00
Justin Starry 813725dfec
Fix ed25519 builtin program handling (#23182)
* Fix ed25519 builtin program handling

* Fix tests

* Add integration tests for processing transactions with ed25519 ixs

* Fix another test

* fix formatting
2022-02-16 18:48:55 +00:00
Michael Vines c42b80f099
Add simulation detection countermeasure (#22880)
* Add simulation detection countermeasures

* Add program and test using TestValidator

* Remove incinerator deposit

* Remove incinerator

* Update Cargo.lock

* Add more features to simulation bank

* Update Cargo.lock per rebase

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
2022-02-15 13:09:59 +01:00
Jack May 3d9874b95a
Add fees to tx-wide caps (#22081) 2022-02-11 16:23:16 -08:00
Brooks Prumo 0a1ab945bc
Move cap_accounts_data_len feature gate only around new error (#23048) 2022-02-10 11:57:00 -06:00
Alexander Meißner 226a71f073
Refactor: Use instruction_trace instead of instruction_context_stack (#22988)
* Moves stack_height of the instruction_trace into InstructionContext.

* Uses nesting_level instead of stack_height internally in transaction_context.rs

* Uses the instruction_trace instead of the instruction_context_stack internally.

* Adds feature gate: record_instruction_in_transaction_context_push.
2022-02-09 20:04:49 +01:00
Jeff Washington (jwash) 205cd4609b
bank::get_rent_collector_from_parent (#23016) 2022-02-09 12:31:58 -06:00
Jeff Washington (jwash) fb47c1f0a3
consolidate Rent construction in test code (#23018) 2022-02-08 21:51:52 -06:00
Brooks Prumo 869cfc9a1c
Return the accounts data len delta after processing messages (#22986) 2022-02-08 19:24:47 -06:00
Brooks Prumo f0f4042680
Put accounts data len updates behind feature gate (#22918) 2022-02-08 08:51:16 -06:00
Justin Starry ba215e94f6
Refactor: Add AccountKeys struct for static and dynamic message keys (#22960) 2022-02-05 20:00:31 +08:00
Alexander Meißner 660f6981c6
Cleanup: TransactionContext (#22910)
* Adds BorrowedAccount::check_sysvar().

* Adds BorrowedAccount::get_data_mut().

* Implements account resizing in BorrowedAccount.

* Exposes is_signer() and is_writable() in InstructionContext.

* Removes AccountMeta and get_instruction_accounts_metas().

* Makes throwing errors in BorrowedAccount optional.

* Removes result return values from BorrowedAccount.
2022-02-03 17:19:42 +01:00
Justin Starry 60af1a4cce
Refactor: Add trait for loading addresses (#22903) 2022-02-03 11:00:12 +00:00
carllin bd1850df25
Return actual committed transactions from process_transactions() (#22802) 2022-02-03 03:56:36 -05:00
Jack May ab02dba96f
Add get_processed_sibling_instruction syscall (#22859) 2022-02-02 16:45:57 -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
Jeff Washington (jwash) fb95fa68a2
cleanup api (#22845) 2022-01-31 11:39:23 -06:00
carllin 94a5aee484
Add new_from_parent() timings (#22744) 2022-01-27 20:35:13 -05:00
Justin Starry 071e97053f
Perf: Reduce write locks on blockhash queue (#22729)
* Perf: Reduce write locks on blockhash queue

* Add comment about thread safety

* Add comment about write starvation
2022-01-26 16:24:27 +08:00
Jon Cinque fc21af4e6e
spl-associated-token-account: Add feature for new program (#22648)
* spl-associated-token-account: Add feature for new program

* Address feedback
2022-01-24 22:54:41 +01:00
Michael Vines 6d5bbca630 Pacify clippy 2022-01-21 19:12:57 -08:00
Brooks Prumo 9977396d8f
Remove unused fields from Bank (#22491) 2022-01-21 06:03:41 -06:00
Justin Starry 7d34a7acac
Perf: Only check executors cache for executable bpf program ids (#22624)
* Only check executors cache for executable bpf program ids

* switch to native loader check

* clean up tests

* fix tests

* clippy
2022-01-21 18:32:30 +08:00
Justin Starry 7f20c6149e
Refactor: move simple vote parsing to runtime (#22537) 2022-01-20 10:39:21 +08: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
Justin Starry cc76a73c49
Refactor: move compute budget runtime logic into solana-program-runtime (#22543) 2022-01-17 20:48:00 +08:00
Justin Starry 2c38a9213f
Revert "Refactor: move compute budget runtime logic into solana-program-runtime (#22533)" (#22542)
This reverts commit b27976626a.
2022-01-17 17:43:17 +08:00
Justin Starry b27976626a
Refactor: move compute budget runtime logic into solana-program-runtime (#22533) 2022-01-17 15:52:33 +08:00
Brooks Prumo 70633b5c2f
Add Bank::accounts_data_len to SetRootMetrics (#22509) 2022-01-14 20:00:07 -06:00
Tao Zhu 9c9f2dd5bd port counting vote CUs to block cost (#22477) 2022-01-14 10:50:29 -06:00
Justin Starry cddab635ff
Cleanup activated rent_for_sysvars feature (#22454) 2022-01-14 20:34:09 +08:00
Michael Vines 4c577d7f8c `Bank::get_fee_for_message` is now nonce aware 2022-01-13 17:27:38 -08:00
Jeff Washington (jwash) 7711cd74c3
partition_from_pubkey (#22430)
* Revert "chore: bump dashmap from 4.0.2 to 5.0.0 (#21824)"

This reverts commit 8aa3d690b5.

* partition_from_pubkey
2022-01-13 17:02:42 -06: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
Justin Starry 7171c95bdd Refactor: move sysvar cache to new module 2022-01-12 12:35:28 -07:00
Tyera Eulberg 3ca16de851
Only examine explicit tx accounts for rent state (#22441)
* Add failing test

* Fix: only examine accounts explicitly included in a tx
2022-01-11 20:23:51 -07:00
Brooks Prumo c45dde6164
Handle accounts data size changes due to rent-collected accounts (#22412) 2022-01-11 17:20:28 -06:00
Tyera Eulberg 637e366b18
Prevent rent-paying account creation (#22292)
* Fixup typo

* Add new feature

* Add new TransactionError

* Add framework for checking account state before and after transaction processing

* Fail transactions that leave new rent-paying accounts

* Only check rent-state of writable tx accounts

* Review comments: combine process_result success behavior; log and metrics before feature activation

* Fix tests that assume rent-exempt accounts are okay

* Remove test no longer relevant

* Remove native/sysvar special case

* Move metrics submission to report legacy->legacy rent paying transitions as well
2022-01-11 11:32:25 -07:00
Brooks Prumo 9bc2592da1
Use lazy_rent_collection directly (#22410) 2022-01-10 10:47:08 -06:00
Trent Nelson 3b4aad9df1 bank: fix executor cache metrics 2022-01-09 04:22:39 +00:00
Brooks Prumo d90d5ee9b6
Refactor Rent::due() with RentDue enum (#22346) 2022-01-08 09:03:46 -06:00
Jack May 4a9f4e2505 improve multi executor cache addition 2022-01-08 03:47:23 -07:00
Trent Nelson ad3cb0bc93 --amend 2022-01-08 08:19:27 +00:00
Trent Nelson 4ce48307bb bank: prime new executor cache entry use-counts 2022-01-08 08:19:27 +00:00
Trent Nelson 6d76db1de5 bank: Add executors cache metrics 2022-01-07 16:53:27 -07:00
behzad nouri c2389fc209
removes CowCachedExecutors (#22343)
Copy-on-write semantics for cached executors can be implemented by a
simple Arc<CachedExecutors> as opposed to CowCachedExecutors:
https://github.com/solana-labs/solana/blob/f1e2598ba/runtime/src/bank.rs#L244-L247

This will also avoid the need for double locking as in:
https://github.com/solana-labs/solana/blob/f1e2598ba/runtime/src/bank.rs#L3490-L3491
https://github.com/solana-labs/solana/blob/f1e2598ba/runtime/src/bank.rs#L3525-L3526
2022-01-07 14:06:29 +00:00
Justin Starry 52d12cc802
Add runtime support for address table lookups (#22223)
* Add support for address table lookups in runtime

* feedback

* feedback
2022-01-07 11:59:09 +08:00
Jack May f1e2598baa
Retain executor cache counts (#22322) 2022-01-06 08:56:00 -08:00
Trent Nelson 72fc6096a0 Use saturating_add_assign macro 2022-01-06 03:56:46 -07:00
Carl Lin b25e4a200b Add execute metrics 2022-01-06 03:56:46 -07:00
Trent Nelson 7d32909e17 move `ExecuteTimings` from `runtime::bank` to `program_runtime::timings` 2022-01-06 03:56:46 -07:00
Jack May 12e160269e
cache executors on failed transactions (#22308) 2022-01-05 22:09:03 -08:00
Justin Starry f2ed6f09ee Skip updating already cached executors if unmodified 2022-01-05 16:08:10 -07:00
Alexander Meißner 9f63493789
Refactor: Remove KeyedAccounts (2) (#22274)
* Adds InstructionContext::get_signers().
Improves error messages when modifying borrowed accounts.

* Removes keyed_accounts from InvokeContext tests.

* Removes keyed_accounts from message_processor.rs

* Removes keyed_accounts from bank.rs

* Removes keyed_accounts from bpf serialization.
2022-01-05 09:39:37 +01:00
Justin Starry 45458e7139
Refactor: Improve type safety and readability of transaction execution (#22215)
* Refactor Bank::load_and_execute_transactions

* Refactor: improve type safety of TransactionExecutionResult

* Add enum for extra type safety in execution results

* feedback
2022-01-05 10:15:15 +08:00
Brooks Prumo 1460f00e0f
Consume from AccountsDataMeter (#21994) 2022-01-04 10:00:21 -06:00
Justin Starry 2b5e00d36d
Limit number of accounts that a transaction can lock (#22201) 2022-01-04 14:25:23 +08: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
carllin 33d0b5e011
Revert "Count compute units even when transaction errors (#22059)" (#22174)
This reverts commit eaa8c67bde.
2021-12-30 02:42:32 -05:00
Justin Starry b1d9a2e60e
Don't forward packets received from TPU forwards port (#22078)
* Don't forward packets received from TPU forwards port

* Add banking stage test
2021-12-29 19:34:31 +01:00
carllin eaa8c67bde
Count compute units even when transaction errors (#22059) 2021-12-28 17:05:11 -05:00
Tyera Eulberg 422a095647
Add (preflight) simulation to BanksClient (#22084)
* Add more-legitimate conversion from legacy Transaction to SanitizedTransaction

* Add Banks method with preflight checks

* Expose BanksClient method with preflight checks

* Unwrap simulation err

* Add Bank simulation method that works on unfrozen Banks

* Add simpler api

* Better name: BanksTransactionResultWithSimulation
2021-12-28 19:25:46 +00:00
Brooks Prumo e3b20c443a
Use load_accounts_data_len() instead of Atomic .load() (#22144) 2021-12-28 13:38:20 +00:00
Brooks Prumo 800472ddf5
Add AccountsDataMeter to InvokeContext (#21813) 2021-12-28 05:14:48 -06: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
Alexander Meißner cc947cad03
Refactor: CPI Instruction Recording (#22111)
* Unifies all InstructionRecorders of a transaction into one.

* Stops explicitly compiling CPI instructions for recording,
uses the indices gathered from instruction_accounts instead.
2021-12-25 13:35:43 +01:00
Jeff Washington (jwash) bdae2993e0
AcctIdx: hold ranges in memory uses multiple threads (#22031) 2021-12-21 17:31:48 -06:00
segfaultdoctor 76098dd42a
RPC Block Subscription (#21787)
* add stuff

* compiling

* add notify block

* wip

* feat: add blockSubscribe pubsub method

* address PR comments

Co-authored-by: Lucas B <buffalu@jito.network>
Co-authored-by: Zano <segfaultdoctor@protonmail.com>
2021-12-17 16:03:09 -07:00
Alexander Meißner 66fa8f9667
Refactor: Removes `Rc` from `Refcell<AccountSharedData>` in the program-runtime (#21927)
* Removes Rc from Rc<RefCell<AccountSharedData>> in the program-runtime.

* Adjusts tests in bpf_loader, system_instruction_processor, config_processor, vote_instruction and stake_instruction
2021-12-17 14:01:12 +01:00
Justin Starry 6ff0be6a82
Clean up demote program write lock feature (#21949)
* Clean up demote program write lock feature

* fix test
2021-12-16 17:27:22 -05:00
Brooks Prumo 635337d2ff
Bank gets accounts data len delta from MessageProcessor::process_message() 2021-12-15 16:41:38 -06:00
Justin Starry c92c09a8be
Remove activated feature for removing inactive delegations from stakes cache (#21732)
* Remove activated feature for removing inactive delegations from stakes cache

* Fix builtin purging
2021-12-14 09:23:36 -05:00
Justin Starry e5476913fe
Remove activated feature that checks tx signature len (#21747) 2021-12-14 09:23:05 -05:00
Jeff Washington (jwash) 90f41fd9b7
use cost model to limit new account creation (#21369)
* use cost model to limit new account creation

* handle every system instruction

* remove &

* simplify match

* simplify match

* add datapoint for account data size

* add postgres error handling

* handle accounts:unlock_accounts
2021-12-12 14:57:18 -06:00
Brooks Prumo eeb97fe7ce
Add accounts_data_len to Bank (#21781) 2021-12-11 09:34:38 -06:00
Justin Starry 9b41ddd9ba
Add address lookup table program (#21616)
* Add address lookup table program

* feedback
2021-12-10 16:02:16 -05:00
Tyera Eulberg 350845c513
Move type alias and use it more broadly (#21763) 2021-12-10 10:46:21 -07:00
Justin Starry fd175c1ea9
Add StakesCache struct to abstract away locking (#21738) 2021-12-10 10:51:33 -05:00
Tyera Eulberg c1386d66e6
Nits in message-processor (#21755)
* Fixup typo

* Simplify types slightly
2021-12-09 23:38:36 -07:00
Justin Starry 6fc329180b
Add more reporting for invalid stake cache members and prune them (#21654)
* Add more reporting for invalid stake cache members

* feedback
2021-12-09 14:12:11 -05:00
Jeff Washington (jwash) 0090916735
skip clean on startup, too (#21718) 2021-12-09 09:36:02 -06: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 a1adcb23b6
Remove activated feature for filtering invalid stakes from rewards (#21641) 2021-12-06 17:56:05 -05:00
Justin Starry 3dab1e711d
Move transaction error code into new module (#21635) 2021-12-06 12:45:33 -05: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
Brooks Prumo 0ef1b25e4b
Make StakeDelegations clone-on-write (#21542) 2021-12-03 08:54:38 -06:00
Alexander Meißner 1a4a039913
Adds feature reject_empty_instruction_without_program. (#21591) 2021-12-03 15:47:18 +01: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
Jack May 976eb81d4f
Cleanup the bank's use of nonces (#21246) 2021-12-02 09:57:05 -08:00
Alexander Meißner bfdb775ffc
Unifies ThisInvokeContext and dyn trait InvokeContext. (#21563) 2021-12-02 18:47:16 +01:00
Trent Nelson 1fae3d24de bank: reuse last hash/fees helper to instatiate `InvokeContext` 2021-12-01 12:59:20 -07:00
Trent Nelson 91c6a10cda bank: get hash and fee rate from the same source when storing accounts 2021-12-01 12:59:20 -07:00
Brooks Prumo cb368e6554
Pass Epoch by value in StakeHistory::get() (#21523) 2021-12-01 08:57:29 -06:00
Alexander Meißner b78f5b6032
Refactor: Cleanup InstructionProcessor (#21404)
* Moves create_message(), native_invoke() and process_cross_program_instruction()
from the InstructionProcessor to the InvokeContext so that they can have a useful "self" parameter.

* Moves InstructionProcessor into InvokeContext and Bank.

* Moves ExecuteDetailsTimings into its own file.

* Moves Executor into invoke_context.rs

* Moves PreAccount into its own file.

* impl AbiExample for BuiltinPrograms
2021-12-01 08:54:42 +01:00
Michael Vines e922c2da9d Update to Rust 1.56.1 2021-11-30 23:28:07 -08:00
ryleung-solana 8cf36e5cb0
Add GPU sigverify for verify path (#20851)
Allows the use of GPU acceleration in verifying the signatures in Entry's after deserialization in the replay stage

Co-authored-by: Stephen Akridge <sakridge@gmail.com>
Co-authored-by: Ryan Leung <ryan.leung@solana.com>
2021-11-30 21:16:13 -05:00
Jeff Washington (jwash) 2be859d304
add test for aborting index scan (#21487) 2021-11-29 16:13:39 -06:00
Michael Vines ba9dfa0d22 Remove frozen account support 2021-11-29 08:38:11 -08:00
Trent Nelson 41cc7af7cd bank: `TransactionLogCollector` - only push address mappings after pushing a log message 2021-11-25 04:50:51 +00:00
Trent Nelson e558ad4c71 bank: don't panic when getting logs from malformed TransactionLogCollector 2021-11-25 04:50:51 +00:00
Trent Nelson dafdc15dfe bank: Add failing test for `TransactionLogCollector::get_logs_for_address()` 2021-11-25 04:50:51 +00:00
Trent Nelson efedb55705 bank: factor tx log getter out to method on `TransactionLogCollector` 2021-11-25 04:50:51 +00:00
Tao Zhu 9edfc5936d
Refactor accounts.rs with Justin's comments to improve lock accounts (#21406)
with results code path.
- fix a bug that could unlock accounts that weren't locked
- add test to the refactored function
- skip enumerating transaction accounts if qos results is an error
- add #[must_use] annotation
- avoid clone error in results
- add qos error code to unlock_accounts match statement
- remove unnecessary AbiExample
2021-11-23 21:17:55 +00:00
Alexander Meißner 22a2537aac
Refactor: Cleanup program-runtime dyn Traits (#21395)
* Unifies dyn Trait ComputeMeter, ThisComputeMeter and TransactionComputeMeter.

* Unifies dyn Trait Logger and ThisLogger.

* Moves Logger to log_collector.rs

* Unifies Logger and LogCollector.

* Removes inner RefCell from LogCollector.

* Adds the log::debug!() message to ic_logger_msg!() again.
2021-11-23 13:23:40 +01:00
sakridge c4d68063c7
Add timing for accounts add_root (#21379) 2021-11-22 18:29:45 +01:00
sakridge cd6f931223
Add timing metrics to bank creation and rewards calculation (#21066) 2021-11-21 15:11:02 +01:00
Jon Cinque 02bc4e3fc1
spl-token: New program feature flag (#21354)
* spl-token: Add feature flag for new release

* Remove all spl token version declarations
2021-11-21 14:27:03 +01:00
Brooks Prumo 0bb059185c
Add lamports_in_rent_paying_accounts to TotalAccountsStats (#21368) 2021-11-19 17:02:23 -06:00
Alexander Meißner 8a50b6302f
Fix #21346 (#21362)
Fixes the empty transaction bug in ThisInvokeContext::push() and adds a test for it to the bank.
2021-11-19 20:43:42 +01:00
Jeff Washington (jwash) 79d21d6805
add --accounts-index-scan-results-limit-mb to allow scans to abort (#21327)
* ScanConfig -> &ScanConfig

* add --accounts-index-scan-results-limit-mb to allow scans to abort

* feedback
2021-11-19 09:00:19 -06:00
Jack May 03c36d240a
Nonce naming cleanup (#21336) 2021-11-18 16:07:17 -08:00
carllin b30c94ce55
ClusterInfoVoteListener send only missing votes to BankingStage (#20873) 2021-11-18 15:20:41 -08:00
Jeff Washington (jwash) 0f69a14247
Add ability to abort scan (#21314) 2021-11-17 13:10:29 -06: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
Jack May cb0bb5bd1e
Nonce accounts must be writeable (#21260)
* Nonce accounts must be writeable

* feedback

* feedback
2021-11-16 23:01:00 +00:00
Jack May 778b5d736c
Load nonce with fixed root (#21248) 2021-11-12 14:12:34 -08:00
Tao Zhu 11153e1f87
refactor cost calculation (#21062)
* - cache calculated transaction cost to allow sharing;
- atomic cost tracking op;
- only lock accounts for transactions eligible for current block;
- moved qos service and stats reporting to its own model;
- add cost_weight default to neutral (as 1), vote has zero weight;

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>

* Update core/src/qos_service.rs

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>

* Update core/src/qos_service.rs

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2021-11-12 01:04:53 -06:00
Brooks Prumo 8b2133b078
Refactor total stats calculation into shared fn (#21212) 2021-11-09 19:13:37 -06: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
Justin Starry 0597594943
Fix rent debits test (#21177) 2021-11-04 20:03:19 +00:00
Jack May 4e527b84b0
Remove unused upgrade epoch handling (#21164) 2021-11-04 10:44:36 -07:00
Jeff Washington (jwash) 171243a370
add rent exempt count to get_total_accounts_stats (#21153) 2021-11-04 11:17:19 -05:00
Justin Starry aaccba8377 Refactor `RentDebits` to use hashmap instead of vec 2021-11-04 15:02:24 +00:00
Alexander Meißner 29ad081555
Stop caching sysvars, instead load them ahead of time. (#21108) 2021-11-04 09:48:34 +01:00
Brooks Prumo c326f41dfe
Add bank::get_total_accounts_stats() (#21159) 2021-11-03 19:23:45 -05:00
Justin Starry 140a5f633d
Simplify replay vote tracking by using packet metadata (#21112) 2021-11-03 09:02:48 +00:00
sakridge 1e5212e60d
Add set_root timing metrics (#21119) 2021-11-02 18:23:35 +01:00
Jack May bced07a099
Update fee api to use blockhash (#21054) 2021-10-29 13:52:59 -07:00
Jeff Washington (jwash) e9ab214237
filler accts: only add filler accts to slots in the current epoch (#21024) 2021-10-28 10:26:30 -05:00
Justin Starry 036d7fcc81
Clean up sanitized tx creation for tests (#21006) 2021-10-27 18:09:16 +01:00
Jeff Washington (jwash) 9d330fc638
FillerAccts: use variable cycle partitions (#20963) 2021-10-27 11:18:27 -05:00
Jack May 1e2bef76e3
Add compute budget program as a noop (#20992) 2021-10-26 20:08:59 -07:00
Jack May 2515f6a04f
Update deprecation versions (#20959) 2021-10-26 09:06:41 -07:00
Jack May bfbbc53dac
Divorce the runtime from FeeCalculator (#20737) 2021-10-22 14:32:40 -07:00
Justin Starry 735016661b
Report timing info for stakes cache updates from txs (#20856) 2021-10-22 12:49:02 -04:00
Alexander Meißner 97c2732d02
Refactor: Cleanup InvokeContext (#20785)
* Move blockhash and fee_calculator in ThisInvokeContext instead of using a reference.

* Moves tx_wide_compute_cap into InvokeContext::push().

* Adds ThisInvokeContext::new_mock() constructor.

* Adds missing loader account in uses of MockInvokeContext.

* Use keyed_account_at_index() when accessing keyed_accounts.

* Makes sysvar interface consistent between ThisInvokeContext and MockInvokeContext,
in order to add InvokeContext::get_sysvars().

* Adds InvokeContext::set_blockhash() and InvokeContext ::set_fee_calculator().

* Adds new_mock_with_features.

* Makes ancestors optional in ThisInvokeContext.

* Adds prepare_mock_invoke_context() and mock_process_instruction().
2021-10-21 20:57:42 +02:00
Jack May 58164517e4
Add program heap bump instruction (#20607) 2021-10-19 21:01:39 -07:00
Tao Zhu 7496b5784b
- make cost_tracker a member of bank, remove shared instance from TPU; (#20627)
- decouple cost_model from cost_tracker; allowing one cost_model
  instance being shared within a validator;
- update cost_model api to calculate_cost(&self...)->transaction_cost
2021-10-19 14:37:33 -05:00
sakridge c9b367c350
Minimum of 1 lamport for rent (#20650) 2021-10-18 19:09:53 +02:00
Alexander Meißner e98cfbb570
Removes deprecated BpfComputeBudget. (#20728) 2021-10-18 09:55:41 +02:00
Jeff Washington (jwash) 70b2e5fef2
hash calc uses all threads during startup (#20735) 2021-10-15 17:41:23 -05:00
Jack May da45be366a
Remove blockhash from fee calculation (#20641) 2021-10-13 13:10:58 -07:00
Jeff Washington (jwash) a8e000a2a6
add filler accounts to bloat validator and predict failure (#20491)
* add filler accounts to bloat validator and predict failure

* assert no accounts match filler

* cleanup magic numbers

* panic if can't load from snapshot with filler accounts specified

* some renames

* renames

* into_par_iter

* clean filler accts, too
2021-10-11 12:46:27 -05: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 db9336c99e
Remove feature switch handling for checking vote init (#20557) 2021-10-08 23:35:26 -04:00
Alexander Meißner 4e65487d2f
Refactor: process_instruction() (#20448)
* Adds first_instruction_account parameter to process_instruction().

* Removes InvokeContext::remove_first_keyed_account() from all BPF loaders.

* Removes InvokeContext::remove_first_keyed_account() from all builtin programs.

* Removes InvokeContext::remove_first_keyed_account() from all mock ups.

* Deprecates InvokeContext::remove_first_keyed_account().

* Documents index base of keyed_account_at_index().

* Adds dynamic offset to call sites of "keyed_account_at_index()".
2021-10-08 11:41:07 +02:00
Jeff Washington (jwash) 069586c171
AcctIdx: set startup around clean and shrink at startup to flush cache (#20526) 2021-10-07 22:57:40 +00:00
Tao Zhu 177a375479
Tpu vote 1.7 (#20187) (#20494)
* Add separate vote processing tpu port

* Add feature to send to tpu vote port

* Add vote rejecting sigverify mode

* use packet.meta.is_simple_vote_tx in place of deserialization

* consolidate code that identifies vote tx atcommon path for cpu and gpu

* new key for feature set

* banking forward tpu vote

* add tpu vote port to dockerfile and other review changes

* Simplify thread id compare

* fix a test; updated cluster_info ABI change

Co-authored-by: Tao Zhu <tao@solana.com>

Co-authored-by: sakridge <sakridge@gmail.com>
2021-10-07 09:38:23 +00:00
Jack May 785fcb63f5
Remove support for dynamically loaded native programs (#20444) 2021-10-06 14:53:23 -07:00
Michael Vines 7027d56064 Resolve nightly-2021-10-05 clippy complaints 2021-10-06 10:37:58 -07: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
Lijun Wang fe97cb2ddf
AccountsDb plugin framework (#20047)
Summary of Changes

Create a plugin mechanism in the accounts update path so that accounts data can be streamed out to external data stores (be it Kafka or Postgres). The plugin mechanism allows

Data stores of connection strings/credentials to be configured,
Accounts with patterns to be streamed
PostgreSQL implementation of the streaming for different destination stores to be plugged in.

The code comprises 4 major parts:

accountsdb-plugin-intf: defines the plugin interface which concrete plugin should implement.
accountsdb-plugin-manager: manages the load/unload of plugins and provide interfaces which the validator can notify of accounts update to plugins.
accountsdb-plugin-postgres: the concrete plugin implementation for PostgreSQL
The validator integrations: updated streamed right after snapshot restore and after account update from transaction processing or other real updates.
The plugin is optionally loaded on demand by new validator CLI argument -- there is no impact if the plugin is not loaded.
2021-09-30 14:26:17 -07:00
Alexander Meißner 57c8abf499
Refactor: Merge message processor into invoke context (#20308)
* Inlines MessageProcessor::execute_instruction() in MessageProcessor::process_message().

* Moves MessageProcessor::create_pre_accounts() into ThisInvokeContext::push().

* Move instruction_recorders slice into InvokeContext.

* Makes account_indices optional in InvokeContext::push().

* Separates initial InvokeContext::push() from ThisInvokeContext::new().

* invoke_context.pop() the base invocation frame.

* Zip message.instructions.iter() and program_indices.iter().

* Moves ThisInvokeContext::new() to the beginning of the loop inside MessageProcessor::process_message().

* Hoists ThisInvokeContext::new() out of loop inside MessageProcessor::process_message().

* Removes unnecessary clone() from ThisInvokeContext::new() in MessageProcessor ::process_message().

* Stop ignoring errors from MessageProcessor::create_pre_accounts().

* Moves MessageProcessor::verify_account_references() and MessageProcessor::verify() into InvokeContext::verify().
2021-09-29 12:05:25 -05:00
Jack May 8fee9a2e1a
Dont call precompiled programs (#19930) 2021-09-29 06:25:08 +00:00
Jack May 491877de3d
Revert "Refactor: Merge MessageProcessor into InvokeContext (#20165)" (#20301)
This reverts commit df6905c3a6.
2021-09-28 16:59:01 -07:00
Jeff Washington (jwash) fa5b091b4c
prior to panicing with cap mismatch, try other calculation (#20292) 2021-09-28 16:09:36 -05:00
Alexander Meißner df6905c3a6
Refactor: Merge MessageProcessor into InvokeContext (#20165)
* Inlines MessageProcessor::execute_instruction() in MessageProcessor::process_message().

* Moves MessageProcessor::create_pre_accounts() into ThisInvokeContext::push().

* Hoists ThisInvokeContext::new() out of loop inside MessageProcessor::process_message().

* Moves MessageProcessor::verify_account_references() and MessageProcessor::verify() into InvokeContext::verify().
2021-09-27 08:28:45 +02:00
Trent Nelson 7b365c564f
runtime: remove inactive delegation from stakes cache 2021-09-22 20:50:58 -06:00
Jeff Washington (jwash) 4dc2f08198
AcctIdx: hold_range_in_memory (#19955) 2021-09-17 22:19:29 +00:00
sakridge dc69cc1ae4
Only allow votes when root distance gets too high (#19917) 2021-09-16 15:12:26 +02:00
Jack May bd434d92e1
nit: misspelling (#19929) 2021-09-16 01:27:26 +00:00
carllin 87a7f00926
Track reset bank in PohRecorder (#19810) 2021-09-13 16:55:35 -07:00
Brooks Prumo 3071c4caad
Set is_startup=true for exhaustively_free_unused_resource() (#19846) 2021-09-13 18:08:06 -05:00
Alexander Meißner 88c1b8f047
Index loaders / executable accounts (#19469)
* Appends loaders / executable_accounts to accounts in transaction loading.

* Adds indices to loaders / executable_accounts.

* Moves MessageProcessor::create_keyed_accounts() into InvokeContext::push().

* Removes "executable_accounts",
now referenced by transaction wide index into "accounts".

* Removes create_pre_accounts() from InstructionProcessor,
as it is already in MessageProcessor.

* Collect program account indices directly in load_executable_accounts().
2021-09-10 08:36:21 +02:00
Jeff Washington (jwash) df5befdaca
metrics on rent partitions (#19728) 2021-09-09 10:50:35 -05:00
Jeff Washington (jwash) 8489ee7df9
Revert "collect rent in parallel for partitions (#19478)" (#19723)
This reverts commit 1560d5e3c3.
2021-09-08 21:27:08 -05:00
Tyera Eulberg 38bbb77989
Return error if Transaction contains writable executable or ProgramData accounts (#19629)
* Return error if Transaction locks an executable as writable

* Return error if a ProgramData account is writable but the upgradable loader isn't present

* Remove unreachable clause

* Fixup bpf tests

* Review comments

* Add new TransactionError

* Disallow writes to any upgradeable-loader account when loader not present; remove is_upgradeable_loader_present exception for all other executables
2021-09-08 15:21:52 -06:00
sakridge 3a8c678f62
Remove some copying (#19691) 2021-09-08 18:32:38 +02:00
Jeff Washington (jwash) 456bf15012
AccountsIndexConfig -> AccountsDbConfig (#19687) 2021-09-08 04:30:38 +00:00
Jeff Washington (jwash) 1560d5e3c3
collect rent in parallel for partitions (#19478)
* collect rent in parallel for partitions

* combine use

* use fg accounts db thread pool
2021-09-07 11:51:59 -05:00
Sean Young d461a9ac10 verify_precompiles needs FeatureSet
Rather than pass in individual features, pass in the entire feature set
so that we can add the ed25519 program feature in a later commit.
2021-09-05 18:59:37 +01:00
Tyera Eulberg decec3cd8b
Demote write locks on transaction program ids (#19593)
* Add feature

* Demote write lock on program ids

* Fixup bpf tests

* Update MappedMessage::is_writable

* Comma nit

* Review comments
2021-09-04 03:05:30 +00: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
Jack May 170927b7c4
nit: Move builtins types to builtins file (#19597) 2021-09-02 21:29:11 -07:00
Jeff Washington (jwash) 6ab8286e8d
add logging for a handful of tests (#19582) 2021-09-02 16:32:19 -05:00
Jeff Washington (jwash) f5388cfe71
tests which assert or panic in other threads now will report an error (#19532)
* tests which assert or panic in other threads now will report an error

* rename, add assert detecting time out
2021-09-02 11:26:57 -05:00
Tyera Eulberg 0088aefa24
Fix tests that make assumptions about tx fee rate (#19537) 2021-08-31 22:02:14 -06:00
behzad nouri 8ad52fa095
implements copy-on-write for vote-accounts (#19362)
Bank::vote_accounts redundantly clones vote-accounts HashMap even though
an immutable reference will suffice:
https://github.com/solana-labs/solana/blob/95c998a19/runtime/src/bank.rs#L5174-L5186

This commit implements copy-on-write semantics for vote-accounts by
wrapping the underlying HashMap in Arc<...>.
2021-08-30 15:54:01 +00:00
Justin Starry 2d7f036afd
Add solana-program-runtime crate (#19438) 2021-08-27 00:30:36 +00:00
Jeff Washington (jwash) 98bc694606
hash calculation adds really old slots to dirty_stores (#19434) 2021-08-26 14:32:43 -05:00
Jeff Washington (jwash) 535de3b302
add test for test_clean_nonrooted (#19409) 2021-08-26 13:56:09 -05:00
Brooks Prumo 234461f779
Add base_slot to get_snapshot_storages() (#19348) 2021-08-20 16:23:43 -05: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
Jack May 3ec33e7d02
Fail secp256k1 if the instruction data looks incorrect (#19300) 2021-08-19 13:13:54 -07:00
Tyera Eulberg c167211611
Expose genesis block time via rpc (#19267)
* Expose genesis_creation_time from Bank

* Backfill genesis_creation_time for block/block-time requests of slot 0
2021-08-17 16:29:34 -06:00
Justin Starry c50b01cb60
Store versioned transactions in the ledger, disabled by default (#19139)
* Add support for versioned transactions, but disable by default

* merge conflicts

* trent's feedback

* bump Cargo.lock

* Fix transaction error encoding

* Rename legacy_transaction method

* cargo clippy

* Clean up casts, int arithmetic, and unused methods

* Check for duplicates in sanitized message conversion

* fix clippy

* fix new test

* Fix bpf conditional compilation for message module
2021-08-17 15:17:56 -07:00
Jeff Washington (jwash) 7c70f2158b
accounts_index_bins to AccountsIndexConfig (#19257)
* accounts_index_bins to AccountsIndexConfig

* rename param bins -> config

* rename BINS_FOR* to ACCOUNTS_INDEX_CONFIG_FOR*
2021-08-17 14:50:01 -05:00
Jeff Washington (jwash) 7481d9b66b
exhaustively_free_unused_resource uses more threads (#19264) 2021-08-17 12:38:41 -05:00
Jeff Washington (jwash) 1a3f29e22d
rework bank test to specifically use BTreeMap (#19225) 2021-08-13 13:30:48 -05:00
Jack May 0b50bb2b20
Deprecate FeeCalculator returning APIs (#19120) 2021-08-13 09:08:20 -07:00
Brooks Prumo 5fb6b341c4
Handle cleaning of zero-lamport accounts w.r.t. Incremental Snapshots (#18870)
* Handle cleaning zero-lamport accounts

Handle cleaning zero-lamport accounts in slots higher than the last full
snapshot slot.  This is part of the Incremental Snapshot work.

Fixes #18825
2021-08-12 15:56:08 -05:00
Tao Zhu 414d904959
Reject blocks for costs above the max block cost (#18994)
* added realtime cost checking logic to reject block that would exceed max limit:
- defines max limits at block_cost_limits.rs
- right after each bath's execution, accumulate its cost and check again
  limit, return error if limit is exceeded

* update abi that changed due to adding additional TransactionError

* To avoid counting stats mltiple times, only accumulate execute-timing when a bank is completed

* gate it by a feature

* move cost const def into block_cost_limits.rs

* redefine the cost for signature and account access, removed signer part as it is not well defined for now

* check if per_program_timings of execute_timings before sending
2021-08-12 10:48:47 -05:00
Justin Starry 446816de52
Remove redundant is_stake check (#19185) 2021-08-11 18:38:03 +00:00
Tyera Eulberg 5970083b4d
Use last_valid_block_height in services and client apps (#19163)
* Add deprecated tag to Bank::get_blockhash_last_valid_slot

* Update SendTransactionService to use last_valid_block_height

* Update solana-tokens to use last_valid_block_height

* Remove dangling file

* Update solana program to use last_valid_block_height

* Update Banks crates to use last_valid_block_height
2021-08-11 01:04:00 -06:00
behzad nouri 00e5e12906 renames solana_runtime::vote_account::VoteAccount
Rename:
  VoteAccount    -> VoteAccountInner  # the private type
  ArcVoteAccount -> VoteAccount       # the public type
2021-08-10 22:54:17 +00:00
Brooks Prumo faf99f4760
Move Bank::get_incremental_snapshot_storages() into snapshot_utils (#19155)
Filtering out storages for incremental snapshots will be needed by the
background services for incremental snapshot support, but there is not a
Bank at that point.  Since the filtering doesn't apply only to Bank, and
more to snapshots, move the functionality into snapshot_utils.
2021-08-10 14:04:11 -05:00
Jeff Washington (jwash) 651343688d
Use option for account index bucket parameter (#19150) 2021-08-10 11:32:25 -05:00
behzad nouri f302774cf7
implements copy-on-write for staked-nodes (#19090)
Bank::staked_nodes and Bank::epoch_staked_nodes redundantly clone
staked-nodes HashMap even though an immutable reference will suffice:
https://github.com/solana-labs/solana/blob/a9014cece/runtime/src/vote_account.rs#L77

This commit implements copy-on-write semantics for staked-nodes by
wrapping the underlying HashMap in Arc<...>.
2021-08-10 12:59:12 +00:00
Jeff Washington (jwash) 47e0d9aa95
plumb more accounts_index bins (#19123) 2021-08-10 05:45:46 -05:00
Jeff Washington (jwash) 5874f75a26
restore name: Bank::new_with_paths (#19122) 2021-08-09 17:30:37 -05:00
Jeff Washington (jwash) 216a1b3d74
remove Bank::default() (#19099) 2021-08-06 13:10:13 -05:00
Jeff Washington (jwash) ca37873e16
rework bank::new_with_paths (#19087)
* rework bank::new_with_paths

* missing 1 bench
2021-08-06 09:30:40 -05:00
Jeff Washington (jwash) 0028442e14
rework defaults and construction of accountsdb, accounts, bank (#19083)
* rework defaults and construction of accountsdb, accounts, bank

* merge issues
2021-08-05 17:27:13 -05:00
Jeff Washington (jwash) e368f10973
add _for_tests to new_no_wallclock_throttle (#19086) 2021-08-05 14:50:25 -05:00
Jeff Washington (jwash) a9014ceceb
Bank::default_for_tests() (#19084) 2021-08-05 11:53:29 -05:00
Jeff Washington (jwash) 14361906ca
for all tests, bank::new -> bank::new_for_tests (#19064) 2021-08-05 08:42:38 -05:00
Jeff Washington (jwash) bde9b4de94
Bank::new -> Bank::new_for_benches (#19063) 2021-08-04 17:30:43 -05:00
Jeff Washington (jwash) 3280ae3e9f
add validator option --accounts-db-skip-shrink (#19028)
* add validator option --accounts-db-skip-shrink

* typo
2021-08-04 17:28:33 -05:00
Jeff Washington (jwash) 1ed12a07ab
introduce Bank::new_for_tests (#19062) 2021-08-04 15:06:57 -05:00
Trent Nelson 79b4b83d3c runtime: remove unused `allow` attrs 2021-08-04 07:21:55 +00:00
Jack May 77861e2d40
Feature disable fees sysvar (#18981)
* Feature disable fees sysvar

* nudge
2021-08-02 00:31:11 +00:00
Trent Nelson 21bc43ed58
nonce: Unify `NonceError` with `SystemError` 2021-07-30 14:47:14 -06:00
Jack May dfbb0c559b
deprecate fees sysvar (#18960) 2021-07-29 10:48:14 -07:00
Jack May 9529284194
Nonce gets blockhash from invoke_context (#18950) 2021-07-29 01:50:20 -07:00
Jack May 0167daa116
cleanup feature consistent_recent_blockhashes_sysvar (#18932) 2021-07-28 10:25:33 -07:00
Jack May 72e374d0f3
Deprecate SysvarRecentBlockhashes (#18875) 2021-07-27 16:34:21 -07:00
Brooks Prumo d1debcd971
Add incremental snapshot utils (#18504)
This commit adds high-level functions for creating and loading-from
incremental snapshots, plus all low-level functions required to perform
those tasks.  This commit **does not** add taking incremental snapshots
as part of a running validator, nor starting up a node with an
incremental snapshot; just laying ground work.

Additionally, `snapshot_utils` and `serde_snapshot` have been
refactored to use a common code paths for the different snapshots.

Also of note, some renaming has happened:
  1. Snapshots are now either `full_` or `incremental_` throughout the
     codebase.  If not specified, the code applies to both.
  2. Bank snapshots now are called "bank snapshots"
     (before they were called "slot snapshots", "bank snapshots", or
      just "snapshots").  The one exception is within `Bank`, where they
     are still just "snapshots", because they are already "bank
     snapshots".
  3. Snapshot archives now have `_archive` in the code.  This
     should clear up an ambiguity between bank snapshots and snapshot
     archives.
2021-07-22 14:40:37 -05:00
Jack May 7fc4cfebc8
Rename BpfComputeBudget (#18768) 2021-07-22 10:18:51 -07:00
Jon Cinque 51f3b9aa7c
feature: add new token program feature (#18780)
* feature: add new token program feature

* Fixup test

* Update to spl-token v3.2.0

* Update Cargo.lock + fmt

* Update token program version in fetch-spl.sh

* Bump associated token program to 1.0.3

* Add aToken so
2021-07-21 14:34:25 +02:00
Jack May 7ed8792647
Use saturating math for timings (#18735) 2021-07-19 11:05:10 -07:00
Jack May 74539020b4
Transaction simulation includes cost (#18715) 2021-07-16 14:58:15 -07:00
Jack May 6cf3c1ab8f
tx wide compute budget (#18631) 2021-07-16 00:31:22 -07:00
Justin Starry d166b9856a
Move transaction sanitization earlier in the pipeline (#18655)
* Move transaction sanitization earlier in the pipeline

* Renamed HashedTransaction to SanitizedTransaction

* Implement deref for sanitized transaction

* bring back process_transactions test method

* Use sanitized transactions for cost model calculation
2021-07-15 22:51:27 -05:00
Trent Nelson 3a85b77bb5 hijack secp256k1 enablement feature plumbing for libsecp256k1 upgrade 2021-07-15 18:43:55 +00:00
Trent Nelson 568660b402 Revert "Remove feature switch for secp256k1 program (#18467)"
This reverts commit fd574dcb3b.
2021-07-15 18:43:55 +00:00
sakridge 7f2254225e
Move entry/poh to own crate to speed up poh bench build (#18225) 2021-07-14 14:16:29 +02:00
Michael Vines 4098af3b5b Record vote account commission with voting/staking rewards and surface in RPC 2021-07-12 15:09:44 -07:00
Justin Starry e806d31224
Optimize Message::is_non_loader_key method (#18579) 2021-07-12 10:42:22 -05:00
Ryo Onodera b0734fabf7 Improve test 2021-07-09 09:08:38 -07:00
Ryo Onodera bd3c93f086 Add expected test removal remainder 2021-07-09 09:08:38 -07:00
Ryo Onodera 30a8fb86d0 Fix comment 2021-07-09 09:08:38 -07:00
Ryo Onodera b158353ca9 kill single letter variables 2021-07-09 09:08:38 -07:00
Ryo Onodera 0f1c0c2796 Improve comment 2021-07-09 09:08:38 -07:00
Ryo Onodera 3a7e5e65e4 Fix rebase... 2021-07-09 09:08:38 -07:00
Ryo Onodera f029af0fca Remove sysvar special cases for rent and assign 2021-07-09 09:08:38 -07:00
Justin Starry fd574dcb3b
Remove feature switch for secp256k1 program (#18467)
* Remove feature switch for secp256k1 program

* fix tests
2021-07-09 10:08:03 -05:00
Ryo Onodera d69f469b83
Record parent slot to reconstruct fork tree from influxdb (#18482) 2021-07-07 15:56:38 +00:00
Justin Starry 100fabf469
Remove feature switch for demoting sysvar write locks (#18373) 2021-07-06 21:22:22 +00:00
Justin Starry 5dd399dafa
Fix transaction logs and inner ixs for leader nodes (#18395)
* Fix transaction logs and inner ixs for leader nodes

* Fix cpi log storage flag
2021-07-06 19:35:24 +00:00
Alexander Meißner 7462c27d07
Refactoring: Unify account_deps and accounts (#17898)
* Changes ThisInvokeContext::get_account() to use accounts instead of pre_accounts.

* Adds explicit keys to accounts to make them symmetric to account_deps.

* Appends account_deps to accounts in transaction loading and removes account_deps everywhere else.
2021-07-05 13:49:37 +02:00
Justin Starry d5961e9d9f
Reject transactions with extra signatures (#18306)
* Reject transactions with extra signatures

* fix tests

* fix check

* fix check

* tx method

* fix checks
2021-07-01 18:06:59 +00:00
Justin Starry 5ca975383c
Remove feature switch for using message hash for already processed check (#18340) 2021-07-01 09:33:55 -05:00
Trent Nelson d3a7e22112 sdk: refactor pda generation 2021-06-30 19:01:51 -06:00
Justin Starry b08f8bd1b0
Fail simulation if transaction contains duplicate accounts (#18304) 2021-06-30 13:50:55 -05:00
Jeff Washington (jwash) fbc94d84c8
apply 'debug_do_not_add_builtins' to feature activations (#18110) 2021-06-22 14:21:49 -05:00
sakridge e808f34b0b
Add batch stats (#18096) 2021-06-22 15:23:26 +02:00
Tyera Eulberg 19fe1dd463
Move stake_weighted_timestamp module (#18114)
* Move timestamp module into runtime

* Less public

* Remove unused enum
2021-06-21 16:14:54 -06:00
Alexander Meißner 789f33e8db chore: cargo fmt 2021-06-18 10:42:46 -07:00
Alexander Meißner 6514096a67 chore: cargo +nightly clippy --fix -Z unstable-options 2021-06-18 10:42:46 -07:00
Jeff Washington (jwash) dbd4dc04b0
ledger tool limit_load_slot_count_from_snapshot avoids assert failures (#17974) 2021-06-15 15:39:22 -05:00
Jeff Washington (jwash) f558b9b6bf
verify bank hash on startup with ledger tool option (#17939) 2021-06-15 11:52:12 -05: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
carllin ccc013e134
Handle removing slots during account scans (#17471) 2021-06-14 21:04:01 -07:00
Jeff Washington (jwash) d4cc975fe9
calculate_capitalization uses hash calculation (#17443)
* calculate_capitalization uses hash calculation

* feedback

* remove debugging code, clean up slot math
2021-06-14 08:53:07 -05:00
Lijun Wang 269d995832
Make account shrink configurable #17544 (#17778)
1. Added both options for measuring space usage using total accounts usage and for individual store shrink ratio using an enum. Validator CLI options: --accounts-shrink-optimize-total-space and --accounts-shrink-ratio
2. Added code for selecting candidates based on total usage in a separate function select_candidates_by_total_usage
3. Added unit tests for the new functions added
4. The default implementations is kept at 0.8 shrink ratio with --accounts-shrink-optimize-total-space set to true

Fixes #17544
2021-06-09 21:21:32 -07:00
Jeff Washington (jwash) f6fb8906c7
add data point for cap mismatch (#17746) 2021-06-04 13:54:39 -05:00
carllin bbcdf073ba
Support out of band dumping of unrooted slots in AccountsDb (#17269)
* Accounts dumping logic

* Add test for interaction between cache flush and remove_unrooted_slot()

* Update comments

* Rename

* renaming

* Add more comments

* Renaming

* Fixup test and bad check
2021-06-02 09:51:10 +00:00
Jeff Washington (jwash) 738cc9549f
parallel get_snapshot_storages (#17589) 2021-06-01 19:33:12 -05:00
Jeff Washington (jwash) c8fdf0762c
add Ancestors to get_snapshot_storages to prepare for the future (#17591) 2021-06-01 15:14:35 -05:00
Jeff Washington (jwash) 1d02dba06f
remove unnecessary clone (#17559) 2021-05-28 10:30:01 -05:00
sakridge 49402b7d82
Only add keys with multiple index entries to the clean set (#17473) 2021-05-27 16:31:24 +02:00
Michael Vines 9541411c15 Plumb transaction-level rewards (aka "rent debits") into the `getTransaction` RPC method 2021-05-27 03:05:05 +00:00
Michael Vines cbce440af4 simulateTransaction can now return accounts modified by the simulation 2021-05-26 14:20:23 -07:00
Trent Nelson 2a6c5ed0ac add tests from `RentDebits` 2021-05-26 08:19:10 +00:00
Trent Nelson 97eab7edf9 runtime: add rent debit charges to block metadata 2021-05-26 08:19:10 +00:00
Tyera Eulberg e9bc1c6b07
Add last valid block height to rpc Fees (#17506)
* Add last_valid_block_height to fees rpc

* Add getBlockHeight rpc

* Update docs
2021-05-26 07:26:19 +00:00
Jeff Washington (jwash) 98f1b11edd
Ancestors to HashSet: From(Vec) (#17447)
* ancestors.large_range_slots becomes HashSet

* Ancestors to HashSet: From(Vec)
2021-05-25 11:01:11 -05:00
Jeff Washington (jwash) dd22ae047b
ancestors is set instead of map (#17363) 2021-05-24 17:01:02 -05:00
carllin d8bc56fa51
Refactor purge_slots_from_cache_and_store() and handle_reclaims() (#17319) 2021-05-24 13:51:17 -07:00
jon-chuang ad1f24d487
runtime: Executor usage counts retain only single-epoch memory (#17162) 2021-05-24 12:01:56 -07:00
Jeff Washington (jwash) 0486df02ba
don't limit to thread pool when cleaning on startup (#17317) 2021-05-20 14:36:35 -05:00
Jeff Washington (jwash) a9aa533684
replace Ancestors HashMap for performance (#16477)
* replace Ancestors HashMap for performance

* add ancestors module
2021-05-20 10:11:56 -05:00
Jeff Washington (jwash) c20b27bc8f
shink all in parallel on startup (#17308) 2021-05-19 12:15:24 -05:00
Jeff Washington (jwash) ed9cbd50f0
move Ancestors to its own module (#17316) 2021-05-19 11:50:34 -05:00
Tao Zhu 0781fe1b4f
Upgrade Rust to 1.52.0 (#17096)
* Upgrade Rust to 1.52.0
update nightly_version to newly pushed docker image
fix clippy lint errors
1.52 comes with grcov 0.8.0, include this version to script

* upgrade to Rust 1.52.1

* disabling Serum from downstream projects until it is upgraded to Rust 1.52.1
2021-05-19 09:31:47 -05:00
Jeff Washington (jwash) 75335b4f58
datapoint for verify_snapshot_bank (#17306) 2021-05-18 12:14:43 -05:00
Ryo Onodera bcbe155575
Minor test cleanup and comments (#17283) 2021-05-18 07:22:43 +09:00
Jeff Washington (jwash) 9d6837c904
fix comment (#17286) 2021-05-17 14:06:25 -05:00
Tyera Eulberg 27004f1b76
Return error for excluded secondary-index keys (#17193)
* Add runtime helpers to check secondary indexes for key

* Add custom rpc error

* Check secondary-index key inclusion in rpc

* Clone complete AccountSecondaryIndexes into rpc to avoid bank query
2021-05-13 21:04:21 +00:00
Jeff Washington (jwash) 7d96f78821
include/exclude keys on account secondary index (#17110)
* AccountSecondaryIndexes.include/exclude

* use normal scan if key is not indexed

* add a test to ask for a scan for an excluded secondary index

* fix up cli args
2021-05-11 22:06:22 +00:00
Jeff Washington (jwash) f39dda00e0
type AccountSecondaryIndexes = HashSet (#17108) 2021-05-10 14:22:48 +00:00
Ryo Onodera c616c34825
Add comment for another unspoken eager collection subtlety (#17137) 2021-05-10 22:44:46 +09:00
Ryo Onodera d19526e6c2
Dump rent_collector/inflation with ledger-tool cap (#17069) 2021-05-06 19:29:46 +09:00
Brooks Prumo e6f49a3e79
Clean unrooted unfrozen banks (#16580) (#17003)
Cleanup pubkeys when an unrooted, unfrozen bank is dropped.  This is a
continuation of PR #16911.
2021-05-05 15:02:02 -05:00
sakridge d94e4ef7c9
More docs for bank.rs (#17006) 2021-05-03 17:37:18 +00:00
Jeff Washington (jwash) 541aa5ad85
tests: lamports -> lamports() (#16982) 2021-05-03 10:45:54 -05:00
Jeff Washington (jwash) 744ac1535f
tests: lamports -> ReadableAccount (#16983) 2021-05-03 10:45:15 -05:00
Jeff Washington (jwash) 1a9954f85b
bank deposit checked_add error (#16917)
* bank deposit checked_add error

* add id

* rename variables

* rename error and metric
2021-04-30 16:22:17 -05:00
Jeff Washington (jwash) 01308cd890
distribute_rent_to_validators checked_add_lamports unwrap (#16847)
* distribute_rent_to_validators checked_add_lamports unwrap

* make rent disappear on add failure

* add pubkey to message

* update message text

* don't store account that we failed to transfer to

* format
2021-04-30 16:19:20 -05:00
Jeff Washington (jwash) 763c04adf3
lamports = -> .set_lamports() (#16980) 2021-04-30 21:17:05 +00:00
Brooks Prumo 17e6bd579f
Clean unrooted dropped banks (#16580) (#16911)
In a scenario where a bank is unrooted and dropped, any keys that exist
_only_ in that bank are now cleaned up.

This work was originally based on PR #15106.
2021-04-30 15:34:38 -05:00
Jeff Washington (jwash) ca7b36ad8f
lamports -> lamports() (#16920) 2021-04-29 10:44:46 -05:00
Jeff Washington (jwash) 21c75d9d29
lamports = -> set_lamports (#16919) 2021-04-28 15:39:54 -05:00
Jeff Washington (jwash) a7a671b3aa
AccountSharedData.set_executable() (#16881) 2021-04-28 14:07:43 +00:00
Jeff Washington (jwash) 2021255f91
executable() (#16880) 2021-04-28 08:53:54 -05:00
Jeff Washington (jwash) 1bd623cd15
private AccountSharedData.rent_epoch (#16844) 2021-04-27 13:51:13 -05:00
Jeff Washington (jwash) d533f77301
bank.withdraw uses checked_sub_lamports (#16848)
* bank.withdraw uses checked_sub_lamports

* retain previous codepath for error

* map_err from clippy
2021-04-27 09:58:41 -05:00
Jeff Washington (jwash) 3887169db0
lamports += to checked_add (#16841) 2021-04-27 09:56:18 -05:00
Jeff Washington (jwash) f2ab0384e4
owner -> owner() (#16783) 2021-04-26 17:06:40 +00:00
Jeff Washington (jwash) aeff911c93
owner -> owner() (#16784) 2021-04-26 10:40:11 -05:00
Jeff Washington (jwash) 1a4a7059af
owner -> owner() (#16785) 2021-04-23 15:59:13 -05:00
Jeff Washington (jwash) 48c07d32f0
WritableAccount.add/subtract_lamports (#16750)
* add/sub lamports

* make add/sub return Result

* sample replacements

* cleanup

* fix up a few tests as examples

* move enum, cleanup, impl from

* fmt

* cleanup

* add lamports.rs
2021-04-23 20:20:48 +00:00
Trent Nelson be29568318 runtime: checked math for Bank::withdraw 2021-04-23 20:13:35 +00:00
Jeff Washington (jwash) fb0b76c1f3
account.owner = X -> account.set_owner(X) (#16754) 2021-04-23 12:34:22 -05:00
Jeff Washington (jwash) fc12841d95
Readonlyaccounts (#16743)
* lamports -> lamports()

* format
2021-04-22 20:04:55 +00:00
Jeff Washington (jwash) 333998d008
.lamports = <number> -> .set_lamports(<number>) (#16746) 2021-04-22 18:56:47 +00:00
Jack May 01786f684e
Remove unwrap (#16652) 2021-04-19 20:17:56 -07: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
Trent Nelson 285f3c9d56 Feature-gate hash-based duplicate transaction check 2021-04-16 18:51:18 +00:00
carllin d747614b27
Account for possibility of cache flush in load() (#15454)
* Account for possibility of cache flush in load()

* More cleaning

* More cleaning

* Remove unused method and some comment cleaning

* Fix typo

* Make the detected impossible purge race panic()!

* Finally revert to original .expect()

* Fix typos...

* Add assertion for max_root for easier reasoning

* Reframe races with LoadHint as possible opt.

* Fix test

* Make race bug tests run longer for less flaky

* Delay the clone-in-lock slow path even for RPC

* Make get_account panic-free & add its onchain ver.

* Fix rebase conflicts...

* Clean up

* Clean up comment

* Revert fn name change

* Fix flaky test...

* fmt...

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2021-04-17 00:23:32 +09:00
Brooks Prumo 17aa45fad1 Remove old way of account hashing
Account data hashing used to use different ways of hashing on different
clusters.  That is no longer the case, but the old code still existed.
This commit removes that old, now used code.

**NOTE** The golden hash values in bank.rs needed to be updated.  Since
the original code that selected the hash algorithm used `if >` instead
of `if >=`, this meant that the genesis block's hash _always_ used the
old hashing method, which is no longer valid.

Validated by running `cargo test` successfully.
2021-04-13 14:42:21 -05:00
Justin Starry 85eb37fab0
Merge pull request from GHSA-8v47-8c53-wwrc
* Track transaction check time separately from account loads

* banking packet process metrics

* Remove signature clone in status cache lookup

* Reduce allocations when converting packets to transactions

* Add blake3 hash of transaction messages in status cache

* Bug fixes

* fix tests and run fmt

* Address feedback

* fix simd tx entry verification

* Fix rebase

* Feedback

* clean up

* Add tests

* Remove feature switch and fall back to signature check

* Bump programs/bpf Cargo.lock

* clippy

* nudge benches

* Bump `BankSlotDelta` frozen ABI hash`

* Add blake3 to sdk/programs/Cargo.lock

* nudge bpf tests

* short circuit status cache checks

Co-authored-by: Trent Nelson <trent@solana.com>
2021-04-13 00:28:08 -06:00
Jack May fa83f3bd73
Return sysvars via syscalls (#16422) 2021-04-12 16:04:57 -07:00
Jeff Washington (jwash) 6930a77a0f
prepare replace Ancestors HashMap for performance (#16476) 2021-04-12 10:51:57 -05:00
carllin dc7030ffaa
Allow fork choice to support multiple versions of a slot (#16266) 2021-04-12 01:00:59 -07:00
Jack May 92f4018b07
Cleanup unsupported sysvars (#16390)
* Cleanup unsupported sysvars

* fix ser description
2021-04-06 00:08:03 -07:00
Justin Starry 0596cf5405
Remove unprocessed transactions from log notifications (#16349) 2021-04-04 23:44:59 +08:00
behzad nouri 3f63ed9a72
removes OrderedIterator and transaction batch iteration order (#16153)
In TransactionBatch,
https://github.com/solana-labs/solana/blob/e50f59844/runtime/src/transaction_batch.rs#L4-L11
lock_results[i] is aligned with transactions[iteration_order[i]]:
https://github.com/solana-labs/solana/blob/e50f59844/runtime/src/bank.rs#L2414-L2424
https://github.com/solana-labs/solana/blob/e50f59844/runtime/src/accounts.rs#L788-L817

However load_and_execute_transactions is iterating over
  lock_results[iteration_order[i]]
https://github.com/solana-labs/solana/blob/e50f59844/runtime/src/bank.rs#L2878-L2889
and then returning i as for the index of the retryable transaction.

If iteratorion_order is [1, 2, 0], and i is 0, then:
  lock_results[iteration_order[i]] = lock_results[1]
which corresponds to
  transactions[iteration_order[1]] = transactions[2]
so neither i = 0, nor iteration_order[i] = 1 gives the correct index for the
corresponding transaction (which is 2).

This commit removes OrderedIterator and transaction batch iteration order
entirely. There is only one place in blockstore processor which the
iteration order is not ordinal:
https://github.com/solana-labs/solana/blob/e50f59844/ledger/src/blockstore_processor.rs#L269-L271
It seems like, instead of using an iteration order, that can shuffle entry
transactions in-place.
2021-03-31 23:59:19 +00:00
sakridge 54c68ea83f
Drop write lock on sysvars (#15497)
* Drop write lock on sysvars

* adds env var for demoting sysvar write lock demotion

* moves demote logic to is_writable

* feature gates sysvar write lock demotion

* adds builtins to write lock demotion

* adds system program id to builtins

* adds Feature111...

* adds an abi-freeze test

* mvines set of builtin program keys

Co-authored-by: Michael Vines <mvines@gmail.com>

* update tests

* adds bpf loader keys

* Add test sysvar

* Plumb demote_sysvar to is_writable

* more plumbing of demote_sysvar_write_locks to is_writable

* patches test_program_bpf_instruction_introspection

* hard codes demote_sysvar_write_locks to false for serialization/encoding methods

* Revert "hard codes demote_sysvar_write_locks to false for serialization/encoding methods"

This reverts commit ae3e2d2e777437bddd753933097a210dcbc1b1fc.

* change the hardcoded ones to demote_sysvar_write_locks=true

* Use data_as_mut_slice

Co-authored-by: behzad nouri <behzadnouri@gmail.com>
Co-authored-by: Michael Vines <mvines@gmail.com>
2021-03-30 10:05:09 -07:00
sakridge 5e5b63712b
Status cache improvements (#16174) 2021-03-28 19:10:14 -07:00
Ryo Onodera 6d5c6c17c5
Simplify account.rent_epoch handling for sysvar rent (#16049)
* Add some code for special local testing

* Add comment to store_account_and_update_capitalization

* Simplify account.rent_epoch handling for sysvar rent

* Introduce *_for_test functions

* Add deprecation messages to existing api
2021-03-25 15:23:20 +09:00
carllin f548a04fae
Allow unbounded wallclock processing time in tests (#15961) 2021-03-17 15:48:50 -07:00
carllin c1ba265dd9
Wallclock BankingStage Throttle (#15731) 2021-03-15 17:11:15 -07:00
Justin Starry 918d04e3f0
Add more slot update notifications (#15734)
* Add more slot update notifications

* fix merge

* Address feedback and add integration test

* switch to datapoint

* remove unused shred method

* fix clippy

* new thread for rpc completed slots

* remove extra constant

* fixes

* rely on channel closing

* fix check
2021-03-12 21:44:06 +08:00
Ryo Onodera 4bbeb9c033
Remove old feature: simple_capitalization (#15763)
* Remove old feature: simple_capitalization

* Fix another failing test in core

* Finish up test cleanup

* Further clean up a bit
2021-03-12 11:12:40 +09:00
Jeff Washington (jwash) 952c3bcbb7
AccountSharedData construction (#15790) 2021-03-11 18:09:04 -06:00
Jack May 478518308d
Share RO and Executable accounts within invocations (#15799) 2021-03-10 23:04:00 -08:00
Tyera Eulberg 3355efbb5a
Fix test to use AccountSharedData 2021-03-09 20:47:54 -07:00
Tyera Eulberg 5991cef5f5
Improve load_largest_accounts and add Bank test (#15775) 2021-03-10 00:23:41 +00:00
Jeff Washington (jwash) 52e54e1100
account.data -> data() (#15778) 2021-03-09 22:31:33 +00:00
Jeff Washington (jwash) 8a3135d17b
Account->AccountSharedData (#15691) 2021-03-09 15:06:07 -06:00
Tyera Eulberg e3e8179f2d
Sdk: start to appease clippy's integer arithmetic check (#15736)
* Move to module-level clippy allowance

* Fix stake_weighted_timestamp math

* Fix genesis_config

* Fix shred_version

* Fix hard_forks

* Fix process_instruction

* Add ArithmeticOverflow ix error

* Fix nonce_keyed_account

* Update BankSlotDelta frozen abi due to new ix error
2021-03-08 18:37:57 -07:00
Ryo Onodera beac2d6d3f Remove stale comment 2021-03-08 10:18:32 +09:00
Ryo Onodera 8b0c6db871
Remove old feature: cumulative_rent_related_fixes (#15754) 2021-03-08 09:58:50 +09:00
sakridge c5371fdc85
More debug on shrink and flush (#15518) 2021-03-05 14:10:34 -08:00
Greg Fitzgerald edd159e7d7
Fix typos (#15721) 2021-03-05 07:16:53 +00:00
Tyera Eulberg 872f7117c3
Use OrderedIterator to produce TransactionLogInfo (#15712)
* Add failing test

* Fix iteration_order issue with stored logs
2021-03-04 15:26:19 -07:00
Jack May b53cb8eb2d
Deprecate Instruction::new (#15695) 2021-03-04 05:46:48 +00:00
Jeff Washington (jwash) be35c1c1b7
add execute detail timings (#15638) 2021-03-03 17:07:45 -06:00
Greg Fitzgerald aad79d9d5c
Remove unused Accounts state (#15611)
* Remove dead state from Accounts

* Refactor to remove reference to self.slot

Account::default() has zero lamports, so would return None anyway
2021-03-02 08:28:25 -08:00
sakridge 8399851d11
check program owners (#15495)
* check program owners

* BankSlotDelta should change because InstructionError variant added

Co-authored-by: Tyera Eulberg <tyera@solana.com>
2021-02-26 22:21:34 +00:00
Ryo Onodera 21b43009f6
Introduce ttl eviction for RecycleStore (#15513) 2021-02-25 17:27:27 +09: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
Jack May 2f46da346d
gracefully handle vote account without authorized voter (#15501) 2021-02-24 00:00:24 -08:00
Michael Vines 5df36aec7d Pacify clippy 2021-02-19 20:08:41 -08:00
Michael Vines 5d31763a3b Update ABI digest 2021-02-19 10:54:39 -08:00
Jack May 02432a548f
Cleanup old features (#15391) 2021-02-18 09:56:11 -08:00
Jon Cinque 0f6f6080f3
sdk: Add Borsh support for types and utilities (#15290)
* sdk: Add Borsh to Pubkey

* Add serialization error for easier borsh integration

* Add Borsh usage to banks-client and sdk

* Rename SerializationError -> IOError

* Add new errors to proto

* Update Cargo lock

* Update Cargo.lock based on CI

* Clippy

* Update ABI on bank

* Address review feedback

* Update sanity program instruction count test
2021-02-18 11:14:56 +01:00
Michael Vines 2e7aebf0bb Rework spl_token_v2_self_transfer_fix to avoid any SPL Token downtime 2021-02-12 22:46:39 +00:00
Michael Vines 47c60f8e98 Clean up mainnet-beta inflation candidate features 2021-02-10 17:46:22 -08:00
Jeff Washington (jwash) e59a24d9f9
pass expected capitalization to hash calculation to improve assert msg (#15191)
* cleanup if

* pass expected capitalization to hash calculation to improve assert message

* fix bank function

* one more level

* calculate_accounts_hash_helper

* add slot to error message

* success
2021-02-10 14:38:00 -06:00
Tyera Eulberg da6753b8c0
Warp timestamp and extend max-allowable-drift for accommodate slow blocks (#15204)
* Remove timestamp_correction feature gating

* Remove timestamp_bounding feature gating

* Remove unused deprecated ledger code

* Remove unused deprecated unbounded-timestamp code

* Enable independent adjustment of fast/slow timestamp bounding

* Update timestamp bounds to 25% fast, 80% slow; warp timestamp

* Update bank hash test

* Add PR number to feature

Co-authored-by: Michael Vines <mvines@gmail.com>

Co-authored-by: Michael Vines <mvines@gmail.com>
2021-02-09 15:49:00 -07:00
Jeff Washington (jwash) fabecdc86c
use thread pool for non-index hash calculations (#15149) 2021-02-05 19:48:55 +00:00
behzad nouri 6fd5ec0e4c
caches descendants in bank forks (#15107) 2021-02-05 18:00:45 +00:00
Jeff Washington (jwash) 600ff0d915
calculate hash from store instead of index (#15034)
* calculate hash from store instead of index

* restore update hash in abs
2021-02-04 09:00:33 -06:00
Trent Nelson 85b5dbead6 Add feature for pending SPL Token self-transfer fix 2021-01-29 04:19:33 +00:00
Jack May 63429507b2
Add syscall feature activation test (#14890) 2021-01-27 17:21:25 -08:00
Alexander Meißner 5700e835ef
Refactors tuple of TransactionLoadResult into a struct. (#14773) 2021-01-25 10:35:08 +01:00
carllin c77461e428
Remove unnecesary flushes in previous roots (#14596)
Co-authored-by: Carl Lin <carl@solana.com>
2021-01-23 04:02:44 -08:00
Michael Vines 072e5e54d8 Add generalized voting process to enable full inflation 2021-01-20 23:37:21 -08:00
sakridge 907f518f6d
Add load/execute/store timings (#14561) 2021-01-14 14:14:16 -08:00
carllin 6dfad0652f
Cache account stores, flush from AccountsBackgroundService (#13140) 2021-01-11 17:00:23 -08:00
Tyera Eulberg b0e6e29527
Update timestamp max allowable drift to 50% of PoH (#14531)
* Repurpose warp-timestamp feature for general bump

* Change max_allowable_drift to 50%

* Fill in PR#

* Fix rpc test setup
2021-01-11 23:27:30 +00:00
Jack May 58487c6360
Add buffer authority to upgradeable loader (#14482) 2021-01-08 09:37:57 -08:00
Jack May 0619805806
Upgradeable programs needs program account's address as program id (#14417) 2021-01-04 21:45:05 +00:00
carllin 5affd8aa72
Add secondary indexes (#14212) 2020-12-31 18:06:03 -08:00
Trent Nelson 5b903318b2 vote: Add helper for creating current-versioned states 2020-12-22 19:37:26 -07:00
behzad nouri a14cfd660a
removes &Arc<Self> receivers (#14234) 2020-12-22 23:51:53 +00:00
Jack May ab205b682a
Upgradeable programs called same as non-upgradeable (#14239)
* Upgradeable programs called same as non-upgradeable

* nudge
2020-12-22 09:26:55 -08:00
sakridge baa9602411
Add shrink paths (#14238) 2020-12-21 21:33:37 -08:00
behzad nouri 7b08cb1f0d
improves performance in replay-stage (#14217)
bank::vote_accounts returns a hash-map which is slow to iterate, but all uses
only require an iterator:
https://github.com/solana-labs/solana/blob/b3dc98856/runtime/src/bank.rs#L4300-L4306
Similarly, calculate_stake_weighted_timestamp takes a hash-map whereas it only
requires an iterator:
https://github.com/solana-labs/solana/blob/b3dc98856/sdk/src/stake_weighted_timestamp.rs#L21-L28
2020-12-21 19:18:19 +00:00
Tyera Eulberg e15f95a36f
Fix timestamp handling on ledger warp (#14210)
* Reset timestamp for slot and epoch-start on warp

* Fix genesis timestamp metric source

* Remove check that timestamp > unix_timestamp_from_genesis

Default to previous timestamp, not genesis timestamp

* Move timestamp metrics to report even on warp

* Initialize slot 0 timestamps correctly

* Add feature gate to warp testnet timestamp

* Review suggestion: simplify warp-timestamp slot check
2020-12-20 21:36:56 +00:00
behzad nouri d6d76219b6
caches staked nodes computed from vote-accounts (#13929) 2020-12-17 21:22:50 +00:00
Michael Vines efc091e28a Add transactionCount field to GetEpochInfo 2020-12-17 12:29:50 -08:00
carllin 75e9e321de
Fix race between setting tick height and calculating accounts hash (#14101)
Co-authored-by: Carl Lin <carl@solana.com>
2020-12-15 12:45:40 -08:00
Jack May d513b0c4ca
Add Program loader/environment instruction errors (#14120) 2020-12-15 09:54:07 -08:00
sakridge 5294f70189
Remove some non-warnings (#14115) 2020-12-14 16:26:17 -08:00
Michael Vines e907510a1a clippy 2020-12-14 13:11:50 -08:00
Michael Vines 7143aaa89b Clippy 2020-12-14 08:03:29 -08:00
Ryo Onodera de9ac43ebf
Simple cap by including sysvars and native programs (#13884)
* Simpler cap by including sysvars and native programs

* Fix tests

* Add comment

* revert some unrelated code

* Update test_bank_update_sysvar_account for cap.

* Test cap. for add_native_program using new helper

* Improve the cap adjustment with new tests

* Fix typo...

* Adjust test for improved code coverage

* Rename simpler_capitalization => simple_capitalization

* More rename and bonus commenting
2020-12-14 21:03:24 +09:00
carllin 55fc963595
Move slot cleanup to AccountsBackgroundService (#13911)
* Move bank drop to AccountsBackgroundService

* Send to ABS on drop instead, protects against other places banks are dropped

* Fix Abi

* test

Co-authored-by: Carl Lin <carl@solana.com>
2020-12-13 01:22:34 +00:00
Tyera Eulberg d6eff3d62c
Filter out stake and vote accounts with incorrect owners (#14062)
* Add failing test

* Check stake/vote accounts for validity

* Feature gate change

* Add datapoint

* Add test realism
2020-12-11 12:21:25 -07:00
Ryo Onodera 09bd412b13
Wrong rpc inflation rate (#14063)
* Fix wrong inflation calculation in rpc

* Reorder

* Fix test
2020-12-11 07:42:39 +00:00
Ryo Onodera 164b7895b3
Tiny add_native_program bug fixes with cleanups (#14042)
* Tiny add_native_program bug fixes with cleanups

* Fix typo
2020-12-11 11:03:31 +09:00
Jack May 5ea80e673f
Fix priv escalation test (#14046) 2020-12-10 22:36:33 +00:00
Ryo Onodera 28b014ccf4
Add tests for store_account_and_update_capitalization (#14008) 2020-12-09 00:46:28 +09:00
Alexander Meißner a706706572
Validator CLI option to enable just-in-time compilation of BPF (#13789)
* Adds a CLI option to the validator to enable just-in-time compilation of BPF.

* Refactoring to use bpf_loader_program instead of feature_set to pass JIT flag from the validator CLI to the executor.
2020-12-07 09:49:55 +01:00
Jack May 882d033233
Don't use stale executor cache (#13966) 2020-12-05 05:54:42 +00:00
Trent Nelson 17defbff13 Make `Accounts::is_non_loader_key()` a method on `Message` 2020-12-02 20:10:08 +00:00
Trent Nelson 404fc1570d runtime: Replace `HashAgeKind` with `NonceRollbackInfo` 2020-12-02 20:10:08 +00:00
Trent Nelson 8df2a4bac0 runtime: Factor out `DurableNoncePartial` finishing logic and add tests 2020-12-02 20:10:08 +00:00
behzad nouri e1793e5a13
caches vote-state de-serialized from vote accounts (#13795)
Gossip and other places repeatedly de-serialize vote-state stored in
vote accounts. Ideally the first de-serialization should cache the
result.

This commit adds new VoteAccount type which lazily de-serializes
VoteState from Account data and caches the result internally.

Serialize and Deserialize traits are manually implemented to match
existing code. So, despite changes to frozen_abi, this commit should be
backward compatible.
2020-11-30 17:18:33 +00:00
Ryo Onodera 6048342c57
Enhance ledger-tool for multi-epoch rewards (#13837)
* Support ledger-tool for multi-epoch rewards

* nits

* Ensure not to skip some records in csv
2020-11-27 04:20:47 +00:00
Michael Vines 4ef2da0ff0 Add `solana logs` command 2020-11-25 11:44:41 -08:00
sakridge b70abdc645
Nonce updates (#13799)
* runtime: Add `FeeCalculator` resolution method to `HashAgeKind`

* runtime: Plumb fee-collected accounts for failed nonce tx rollback

* runtime: Use fee-collected nonce/fee account for nonced TX error rollback

* runtime: Add test for failed nonced TX accounts rollback

* Fee payer test

* fixup: replace nonce account when it pays the fee

* fixup: nonce fee-payer collect test

* fixup: fixup: clippy/fmt for replace...

* runtime: Test for `HashAgeKind::fee_calculator()`

* Clippy

Co-authored-by: Trent Nelson <trent@solana.com>
2020-11-24 23:53:51 -08:00
Tyera Eulberg c930f92411
Restore bank feature used to deprecate Rewards sysvar (#13786) 2020-11-24 10:22:31 -07:00
Michael Vines 60ce6f1a9b Truncate logs immediately upon collection. Also reduce limit from 100k to 10k 2020-11-23 17:20:02 -08:00
carllin 791fb17437
Prevent scans on unrooted slots from seeing partial clean (#13628)
Co-authored-by: Carl Lin <carl@solana.com>
2020-11-20 13:01:04 -08:00
Michael Vines 62fa8b0ed8 Demote bank-process_transactions-error counters to info! 2020-11-20 10:43:07 -08:00
Tyera Eulberg c75d97e3f2
Add new inflation feature-ids (#13671)
* Add new inflation feature-ids, and full_inflation default values

* Compute inflation start from full_inflation activation

* Include pico_inflation in inflation start computation

* Add full-inflation constructor

* Align inflation taper with rewards accrual start and catch overflow edge case
2020-11-20 09:54:41 -07:00
Ryo Onodera b74d7b5758
Fix fragile tests in prep of stake rewrite pr (#13654)
* Fix fragile tests in prep of stake rewrite pr

* Restore BOOTSTRAP_VALIDATOR_LAMPORTS where appropriate

* Further clean up

* Further clean up

* Aligh with other call site change

* Remove false warn!

* fix ci!
2020-11-20 17:21:03 +09:00
Ryo Onodera 43d5e47ea9
Rewrite stake accounts for clear migration (#13461)
* Reduce overage stake by rewritng stake accounts

* Write tests and finish implemention

* Create and use new feature gate

* Clean up logging

* Fix typo

* Simplify enable_rewrite_stake

* Fix typo...

* Even simplify gating

* Add metrics
2020-11-20 05:15:06 +09:00
carllin 110acd20dc
Check for overflow in rent partition calculation (#13569)
Co-authored-by: Carl Lin <carl@solana.com>
2020-11-19 04:17:00 -08:00
Tyera Eulberg 645598e615
Improve monitoring of timestamp correction and bounding (#13656)
* Include rejuvenated field in Clock parsing

* Expand timestamp-correction logging info
2020-11-17 21:51:43 +00:00
carllin 6276360468
Prevent scans from seeing root updates/clean (#13464)
Co-authored-by: Carl Lin <carl@solana.com>
2020-11-16 17:23:11 -08:00
Ryo Onodera bcd303a447
ledger-tool cap: delegation owner and stake v2 flag (#13602)
* Output delegation owner as well

* Add --enable-stake-program-v2

* Small cleanup and add sanity assertion

* Fix typo...
2020-11-15 19:38:46 +00:00
Ryo Onodera c97a7d1105
Small cleaning update_epoch_stakes (#13576) 2020-11-13 11:16:38 +00:00
Ryo Onodera 89b474e192
Fix slow/stuck unstaking due to toggling in epoch (#13501)
* Fix slow/stuck unstaking due to toggling in epoch

* nits

* nits

* Add stake_program_v2 feature status check to cli

Co-authored-by: Tyera Eulberg <tyera@solana.com>
2020-11-11 14:11:57 -07:00
Tyera Eulberg c0e2ef06dc
Fix Bank accounts hash mismatch related to Clock::unix_timestamp (#13477)
* Test for different ancestors with mismatch bank hash

* Test cleanup

* Remove nondeterministic ancestor check

* Update timestamp bounding feature key

* Update design doc

* Filter recent_timestamps to nodes voting within the last epoch

Co-authored-by: Stephen Akridge <sakridge@gmail.com>
2020-11-10 02:10:09 +00:00
Ryo Onodera a81e7e7749
Output more inflation calc details in ledger-tool (#13345)
* Output more inflation calc details in ledger-tool

* Fix broken ci...

* Rename confusing variables

* Fix panic by wrapping PointValue with Opiton...

* Minor modifications

* Remove explict needless flush; Drop already does

* Yet another csv field adjustments

* Add data_size and rename epochs to earned_epochs

* Introduce null_tracer

* Unwrap Option in new_from_parent_with_tracer

* Don't shorten identifiers

* Allow irrefutable_let_patterns temporalily

* More null_tracer

* More field adjustments
2020-11-08 16:43:50 +09:00
Tyera Eulberg bc62313c66
Allow feature builtins to overwrite existing builtins (#13403)
* Allow feature builtins to overwrite existing builtins

* Add feature_builtin ActivationType

* Correctly retain idempotent for replacing case

* Fix test

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
2020-11-05 15:37:07 +00:00
Justin Starry c24fbb6f8b
Fix duplicate records of inner instructions (#13380)
* Fix duplicate records of inner instructions

* fix tests

* fix clippy

* Remove bad_inner_instructions
2020-11-05 15:23:52 +08:00
sakridge 43053dcc90
Re-use accounts stores (#12885)
* Re-use accounts_db stores

Creating files and dropping mmap areas can be expensive

* Add test for storage finder

Can encounter an infinite loop when the store is too small, but
smaller than the normal store size.

* Fix storage finding

* Check for strong_count == 1

* try_recycle helper
2020-11-04 09:17:05 -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 e60bda082d Adapt to feature::create_account 2020-11-01 05:53:29 +00:00
Tyera Eulberg 4260b3b416 Sample votes from ancestors back to root 2020-10-31 21:30:42 -07:00
Tyera Eulberg eb2560e782 Prevent block times from ever going backward 2020-10-31 21:30:42 -07:00
Tyera Eulberg 90778615f6 Use bounded timestamp-correction when feature enabled 2020-10-31 21:30:42 -07:00
Tyera Eulberg 80db6c0980 Add bounded timestamp-estimation method 2020-10-31 21:30:42 -07:00
Tyera Eulberg 0049ab69fb Repurpose unused as Clock::epoch_start_timestamp; add gated update 2020-10-31 21:30:42 -07:00
Michael Vines 4b65e32f22 Move Feature struct to solana-program 2020-10-30 17:57:51 -07:00
Michael Vines 7d686b72a0 Add Bank::set_bpf_compute_budget() 2020-10-29 21:45:24 -07:00
Michael Vines 225bed11c7 Remove Entrypoint type 2020-10-29 21:45:24 -07:00
Michael Vines df8dab9d2b Native/builtin programs now receive an InvokeContext 2020-10-29 21:45:24 -07:00
Jack May c458d4b213
move Account to solana-sdk (#13198) 2020-10-28 22:01:07 -07:00
Tyera Eulberg c2dbf53d76
Update FeatureSet::active to include slot-activated (#13256)
* Update FeatureSet::active to include slot-activated

* Clippy suggestion
2020-10-29 02:34:19 +00:00
Ryo Onodera 4698ee5e4a
Improve final report of ledger-tool capitalization (#13232) 2020-10-28 17:10:09 +00:00
Ryo Onodera 7d2962135d
Use pico inflation for ledger-tool capitalization --enable-inflation (#13215)
* Use pico inflation for ledger-tool capitalization --enable-inflation

* rust fmt
2020-10-28 15:30:39 +09:00
Justin Starry 631f029fe9
Account for forward delay in transaction simulation (#13199) 2020-10-27 17:25:08 +00: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
Greg Fitzgerald f58bc8589d
Add Bank::get_signature_status_with_blockhash() (#13167)
Get the signature status in O(1) time, instead of O(n) where
n is the number of blockhashes in the StatusCache.
2020-10-26 23:52:57 +00: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 959880db60 Remove unused pubkey::Pubkey imports 2020-10-21 19:08:13 -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
carllin e6b821c392
Finer grained AccountsIndex locking (#12787)
Co-authored-by: Carl Lin <carl@solana.com>
2020-10-21 17:05:27 -07:00
Ryo Onodera 608b81b412
Port various rent fixes to runtime feature (#12842)
* Port various rent fixes to runtime feature

* Fix CI

* Use more consistent naming...
2020-10-21 22:19:25 +09:00
Michael Vines 6858950f76 Remove frozen ABI modules from solana-sdk 2020-10-20 16:11:30 -07:00
Ryo Onodera c0675968b1
Support Debug Bank (#13017) 2020-10-21 01:05:45 +09:00
Michael Vines 4b04ed86b6 Don't report RewardType::Fee when none was awarded 2020-10-14 09:06:20 -07:00
Jack May c24da1ee16
fix native_loader behavior for invalid accounts (#12814) 2020-10-12 13:40:04 -07:00
Eric Williams 1ab36203de
Retry inflation parameter update along with documentation updates (#12778)
* update initial inflation parameter

* update economics section of docs
2020-10-12 13:10:57 -07:00
Ryo Onodera 2f5bb7e507
Move no-0-rent rent dist. behavior under feature (#12804) 2020-10-12 08:47:52 +00:00