Commit Graph

107 Commits

Author SHA1 Message Date
140c8dd01f Refactor: Replaces KeyedAccount in_get_sysvar_with_account_check (#23905)
* Replaces all use sites of get_sysvar_with_account_check by get_sysvar_with_account_check2.

* Removes get_sysvar_with_account_check.

* Renames get_sysvar_with_account_check2 to get_sysvar_with_account_check.
2022-03-24 19:30:42 +01:00
0ed23899e7 directly use compute_budget MAX_UNITS and DEFAULT_UNITS 2022-03-18 08:53:11 -05:00
a4cacf3389 add deterministic default cost 2022-03-18 08:53:11 -05:00
9ed056424c Remove unused InstructionRecorder and some SanitizedMessage methods (#23723) 2022-03-17 20:25:12 +08:00
dda3a463a2 Fix duplicate account translation in CPI (#23701)
* Use visit_each_account_once() in CPI syscall to prevent duplicate accounts from being translated twice.

* remove unwrap() from runtime

Co-authored-by: Jack May <jack@solana.com>
2022-03-16 22:45:01 +00:00
c68c0e881e consolidate use-jit flag (#23652) 2022-03-14 15:00:00 -07:00
bf57252298 deny slice indexing (#23622) 2022-03-13 08:43:07 -07:00
3c6840050c Ensure blocks do not exceed the max accounts data size during Replay Stage (#23422) 2022-03-10 10:24:31 -06:00
7b7160448b Rename AccountsDataMeter::consume (#23037) 2022-03-03 12:23:06 -06:00
d0e85c293f Fix rustfmt check (#23296) 2022-02-23 16:38:53 +08:00
0a3a18744f Update the consumed compute units cost for hashing syscalls
This change prevents zero-cost computation of hash functions on
unbound number of zero-length slices of data.  The cost for each slice
is at least equal to the base cost of a memory operation, but could be
more for longer slices.
2022-02-23 02:32:41 +00:00
20d031e2b8 Refactor ExecuteTimings w/ enum-indexed array (#23085) 2022-02-22 14:46:56 -08:00
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
ee7e411d68 Replaces KeyedAccount by BorrowedAccount in system_instruction_processor. (#23217)
* Adds InstructionContext::check_number_of_instruction_accounts() and InstructionContext::get_instruction_account_key().
Bases check_sysvar_account() on instuction account indices.

* Adds instruction_account_indices enums to system_instruction_processor.

* Reorders parameters and adds InstructionContext.

* Replaces KeyedAccount by BorrowedAccount in system_instruction_processor (part 1).

* Replaces KeyedAccount by BorrowedAccount in system_instruction_processor (part 2).

* Replaces KeyedAccount by BorrowedAccount in system_instruction_processor (part 3).

* Replaces KeyedAccount by BorrowedAccount in system_instruction_processor (part 4).

* Replaces KeyedAccount by BorrowedAccount in system_instruction_processor (part 5).

* Code cleanup
2022-02-19 02:06:33 +01:00
1a68f81f89 Replaces KeyedAccount by BorrowedAccount in nonce_keyed_account. (#23214)
* Adds get_sysvar_with_account_check2 for ABIv2.

* Replaces get_signers() and get_sysvar_with_account_check() in system_instruction_processor.

* Replaces KeyedAccount by BorrowedAccount in nonce_keyed_account.
2022-02-17 17:36:55 +01:00
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
619335df1a Add execute timings (#23097) 2022-02-17 01:14:32 -05:00
3d9874b95a Add fees to tx-wide caps (#22081) 2022-02-11 16:23:16 -08:00
0a1ab945bc Move cap_accounts_data_len feature gate only around new error (#23048) 2022-02-10 11:57:00 -06:00
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
869cfc9a1c Return the accounts data len delta after processing messages (#22986) 2022-02-08 19:24:47 -06:00
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
c16cf9cf8a Refactor: Use SysvarCache in all builtin programs (#22864)
* Replaces from_keyed_account() by SysvarCache in stake instruction.

* Replaces from_keyed_account() by SysvarCache in system instruction processor.

* Removes from_keyed_account().
Moves check_sysvar_keyed_account() into sysvar_cache.rs

* Removes tests which test for incorrectly serialized sysvars.
2022-02-03 13:03:50 +01:00
cc94a93b56 Safer invoke context (#22898)
* Safer invoke context

* feedback and rebase with master
2022-02-03 02:34:51 -08:00
ab02dba96f Add get_processed_sibling_instruction syscall (#22859) 2022-02-02 16:45:57 -08:00
551c24da57 nit: consistent name (#22857) 2022-02-01 07:46:04 +00:00
bc800a8d5a Refactor: Unify SysvarCache (#22843)
* Unifies SysvarCache filling in the runtime and tests.
Removes new_mock_with_sysvars_and_features()
Removes mock_process_instruction_with_sysvars().
Replaces from_keyed_account() by SysvarCache in vote processor.

* Replaces from_keyed_account() by SysvarCache in BPF loader.
2022-01-31 17:53:50 +01:00
a71f05f86c Fix CPI duplicate account privilege escalation (#22752)
* Adds TEST_DUPLICATE_PRIVILEGE_ESCALATION_SIGNER and TEST_DUPLICATE_PRIVILEGE_ESCALATION_WRITABLE.

* Moves CPI privilege verification out of deduplication loop.
2022-01-28 00:52:02 +01:00
bee586c6fd fix: Adjust mem op base cost to avoid breaking Raydium AMM Program (#22762) 2022-01-27 02:01:57 +00:00
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
cc76a73c49 Refactor: move compute budget runtime logic into solana-program-runtime (#22543) 2022-01-17 20:48:00 +08:00
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
b27976626a Refactor: move compute budget runtime logic into solana-program-runtime (#22533) 2022-01-17 15:52:33 +08:00
93a7b94507 Add benchmark for vote processing (#22486) 2022-01-14 17:10:17 +08:00
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
7171c95bdd Refactor: move sysvar cache to new module 2022-01-12 12:35:28 -07:00
aadf4b9b63 Moves InvokeContext::return_data to TransactionContext. (#22411) 2022-01-10 18:26:51 +01:00
390ef0fbcd Consolidate process instruction execution timings to own struct 2022-01-06 03:56:46 -07:00
72fc6096a0 Use saturating_add_assign macro 2022-01-06 03:56:46 -07:00
848b6dfbdd Add metrics for executor creation 2022-01-06 03:56:46 -07:00
b25e4a200b Add execute metrics 2022-01-06 03:56:46 -07:00
7d32909e17 move ExecuteTimings from runtime::bank to program_runtime::timings 2022-01-06 03:56:46 -07:00
0673dc5375 Remove erroneous dbg!() (#22324) 2022-01-06 06:09:15 +00:00
12e160269e cache executors on failed transactions (#22308) 2022-01-05 22:09:03 -08:00
f2ed6f09ee Skip updating already cached executors if unmodified 2022-01-05 16:08:10 -07:00
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
1460f00e0f Consume from AccountsDataMeter (#21994) 2022-01-04 10:00:21 -06:00
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
005592998d Fix bug, add error specific timings (#22225) 2022-01-03 16:33:54 -05:00
e529d03c11 Cleanup #22182 (#22205)
* Turns compute_units_consumed of ProcessInstructionResult into a &mut parameter.

* Removes second nesting level from test_process_instruction_compute_budget().

* Makes test_process_cross_program and test_native_invoke symmetric.

* Unifies test_process_cross_program(), test_native_invoke() and test_process_instruction_compute_budget() into test_process_instruction().
2021-12-31 17:55:27 +01:00