* 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.
warp_to_slot() first warps to one slot before desired slot in order to
freeze the bank at warp slot. This would cause issues when warping by
one slot as that would attempt to warp to the same slot and hit a sanity
check assertion.
* 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.
* 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
* Refactor Bank::load_and_execute_transactions
* Refactor: improve type safety of TransactionExecutionResult
* Add enum for extra type safety in execution results
* feedback
* 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.
* 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().
* 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.
* Unifies all InstructionRecorders of a transaction into one.
* Stops explicitly compiling CPI instructions for recording,
uses the indices gathered from instruction_accounts instead.
* Removes message::Message from invoke_context.rs completely.
* Simplifies sol_invoke_signed() of program-test
* Start search for non program accounts at front (instead of the back).
Program and programdata accounts use rposition(), everything else uses position().
* Introduces InstructionAccount which is like AccountMeta but uses an index instead of a Pubkey
* Renames InvokeContext::create_message() to InvokeContext::prepare_instruction()
* Removes Message and CompiledInstruction from InvokeContext interfaces.
* Resolves TODOs of sol_invoke_signed() in program-test.
* Moves CompiledInstruction::visit_each_account() into invoke_context.rs
* Removes Rc and RefCell from PreAccount
* Splits get_account() into find_index_of_account() and get_account_at_index()
in order to remove Rc from return type.
- Lets InvokeContext::process_cross_program_instruction() handle the first invocation depth too.
- Marks InvokeContext::verify(), InvokeContext::verify_and_update() and InvokeContext::process_executable_chain() private.
- Renames InvokeContext::process_cross_program_instruction() to InvokeContext::process_instruction().
- Removes InvokeContext::new_mock_with_sysvars().
* 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
For writing tests, it is often desirable to create a certain situation
that would be tedious, or even impossible to create by sending
individual transactions.
For example, a common attack vector on Solana is to create a copy of
some existing account that stores configuration data, but manipulate the
data stored there, and then to call a program and pass in the
manipulated account, instead of the real account.
If one wants to test this, one option is to write a program that you can
call to write arbitrary data into a new account account (and possibly
change its owner), then include that program in the test context, and
send a transaction to call it. This is extremely tedious, and developers
are not going to bother doing it. I myself would rather fork
solana-program-test to add this `set_account` method, than to write that
program. Having a “god mode” method to just write an account, lowers the
barrier to writing comprehensive tests.
A second reason for introducing this method, is defense in depth. There
may be states of the bank that are not reachable *yet* by only sending
transactions, but that you might want to test against either way. For
example, right now, the balance of a stake account cannot decrease
without going through the stake program. But what if Solana were to
introduce slashing in the future, and you want to ensure your program is
robust against decreases in stake account balance? Right now there is no
way to test this, but by introducing this “god mode” to write accounts,
the situation becomes testable.
* 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>
* 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().
* banks_server: Reduce sleep duration for local server
This speeds up process_transaction_with_commitment_and_context()
and thus most program tests by a lot.
* Plumb tick duration through poh config and signature polling
Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
* 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()".
* Removes search for accounts and unsafe lifetime transmute in InvokeContext::push().
* Replaces accounts by account_indices in verify_and_update() and process_cross_program_instruction().
Co-authored-by: Justin Starry <justin.m.starry@gmail.com>
* 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().
* 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
* 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.
* document ProgramTest::new
* simplify ProgramTest::new doc-string
* make ProgramTest::add_program noisier
`add_program` (and `new`, implicitly) now prints a warning when the user
supplies a bogus program name to a ProgramTest and invokes `test-bpf`.
Additionally, it is now impossible to ask for a regular `test` and for
the generated ProgramTest to load BPF code instead of native code.
Previously, this was caused by a precedence issue: BPF code would always
be preferred over native if the program name was valid, regardless of
user choice.