Nits in message-processor (backport #21755) (#21761)

* Nits in message-processor (#21755)

* Fixup typo

* Simplify types slightly

(cherry picked from commit c1386d66e6)

# Conflicts:
#	runtime/src/bank.rs
#	runtime/src/message_processor.rs

* Fix conflicts

* Use alias more broadly

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
Co-authored-by: Tyera Eulberg <tyera@solana.com>
This commit is contained in:
mergify[bot]
2021-12-10 21:19:44 +00:00
committed by GitHub
parent 2b2536ac42
commit 87c71647e8
2 changed files with 26 additions and 23 deletions

View File

@ -224,8 +224,9 @@ impl ExecuteTimings {
type BankStatusCache = StatusCache<Result<()>>; type BankStatusCache = StatusCache<Result<()>>;
#[frozen_abi(digest = "5Br3PNyyX1L7XoS4jYLt5JTeMXowLSsu7v9LhokC8vnq")] #[frozen_abi(digest = "5Br3PNyyX1L7XoS4jYLt5JTeMXowLSsu7v9LhokC8vnq")]
pub type BankSlotDelta = SlotDelta<Result<()>>; pub type BankSlotDelta = SlotDelta<Result<()>>;
type TransactionAccountRefCells = Vec<(Pubkey, Rc<RefCell<AccountSharedData>>)>; pub(crate) type TransactionAccountRefCell = (Pubkey, Rc<RefCell<AccountSharedData>>);
type TransactionLoaderRefCells = Vec<Vec<(Pubkey, Rc<RefCell<AccountSharedData>>)>>; type TransactionAccountRefCells = Vec<TransactionAccountRefCell>;
type TransactionLoaderRefCells = Vec<Vec<TransactionAccountRefCell>>;
// Eager rent collection repeats in cyclic manner. // Eager rent collection repeats in cyclic manner.
// Each cycle is composed of <partition_count> number of tiny pubkey subranges // Each cycle is composed of <partition_count> number of tiny pubkey subranges

View File

@ -1,7 +1,8 @@
use { use {
crate::{ crate::{
accounts::Accounts, ancestors::Ancestors, instruction_recorder::InstructionRecorder, accounts::Accounts, ancestors::Ancestors, bank::TransactionAccountRefCell,
log_collector::LogCollector, native_loader::NativeLoader, rent_collector::RentCollector, instruction_recorder::InstructionRecorder, log_collector::LogCollector,
native_loader::NativeLoader, rent_collector::RentCollector,
}, },
log::*, log::*,
serde::{Deserialize, Serialize}, serde::{Deserialize, Serialize},
@ -281,7 +282,7 @@ pub struct ThisInvokeContext<'a> {
invoke_stack: Vec<InvokeContextStackFrame<'a>>, invoke_stack: Vec<InvokeContextStackFrame<'a>>,
rent: Rent, rent: Rent,
pre_accounts: Vec<PreAccount>, pre_accounts: Vec<PreAccount>,
accounts: &'a [(Pubkey, Rc<RefCell<AccountSharedData>>)], accounts: &'a [TransactionAccountRefCell],
programs: &'a [(Pubkey, ProcessInstructionWithContext)], programs: &'a [(Pubkey, ProcessInstructionWithContext)],
logger: Rc<RefCell<dyn Logger>>, logger: Rc<RefCell<dyn Logger>>,
bpf_compute_budget: BpfComputeBudget, bpf_compute_budget: BpfComputeBudget,
@ -304,8 +305,8 @@ impl<'a> ThisInvokeContext<'a> {
rent: Rent, rent: Rent,
message: &'a Message, message: &'a Message,
instruction: &'a CompiledInstruction, instruction: &'a CompiledInstruction,
executable_accounts: &'a [(Pubkey, Rc<RefCell<AccountSharedData>>)], executable_accounts: &'a [TransactionAccountRefCell],
accounts: &'a [(Pubkey, Rc<RefCell<AccountSharedData>>)], accounts: &'a [TransactionAccountRefCell],
programs: &'a [(Pubkey, ProcessInstructionWithContext)], programs: &'a [(Pubkey, ProcessInstructionWithContext)],
log_collector: Option<Rc<LogCollector>>, log_collector: Option<Rc<LogCollector>>,
bpf_compute_budget: BpfComputeBudget, bpf_compute_budget: BpfComputeBudget,
@ -421,7 +422,7 @@ impl<'a> InvokeContext for ThisInvokeContext<'a> {
fn verify_and_update( fn verify_and_update(
&mut self, &mut self,
instruction: &CompiledInstruction, instruction: &CompiledInstruction,
accounts: &[(Pubkey, Rc<RefCell<AccountSharedData>>)], accounts: &[TransactionAccountRefCell],
write_privileges: &[bool], write_privileges: &[bool],
) -> Result<(), InstructionError> { ) -> Result<(), InstructionError> {
let stack_frame = self let stack_frame = self
@ -644,8 +645,8 @@ impl MessageProcessor {
fn create_keyed_accounts<'a>( fn create_keyed_accounts<'a>(
message: &'a Message, message: &'a Message,
instruction: &'a CompiledInstruction, instruction: &'a CompiledInstruction,
executable_accounts: &'a [(Pubkey, Rc<RefCell<AccountSharedData>>)], executable_accounts: &'a [TransactionAccountRefCell],
accounts: &'a [(Pubkey, Rc<RefCell<AccountSharedData>>)], accounts: &'a [TransactionAccountRefCell],
demote_program_write_locks: bool, demote_program_write_locks: bool,
) -> Vec<(bool, bool, &'a Pubkey, &'a RefCell<AccountSharedData>)> { ) -> Vec<(bool, bool, &'a Pubkey, &'a RefCell<AccountSharedData>)> {
executable_accounts executable_accounts
@ -972,8 +973,8 @@ impl MessageProcessor {
/// This method calls the instruction's program entrypoint function /// This method calls the instruction's program entrypoint function
pub fn process_cross_program_instruction( pub fn process_cross_program_instruction(
message: &Message, message: &Message,
executable_accounts: &[(Pubkey, Rc<RefCell<AccountSharedData>>)], executable_accounts: &[TransactionAccountRefCell],
accounts: &[(Pubkey, Rc<RefCell<AccountSharedData>>)], accounts: &[TransactionAccountRefCell],
caller_write_privileges: &[bool], caller_write_privileges: &[bool],
invoke_context: &mut dyn InvokeContext, invoke_context: &mut dyn InvokeContext,
) -> Result<(), InstructionError> { ) -> Result<(), InstructionError> {
@ -1032,7 +1033,7 @@ impl MessageProcessor {
pub fn create_pre_accounts( pub fn create_pre_accounts(
message: &Message, message: &Message,
instruction: &CompiledInstruction, instruction: &CompiledInstruction,
accounts: &[(Pubkey, Rc<RefCell<AccountSharedData>>)], accounts: &[TransactionAccountRefCell],
) -> Vec<PreAccount> { ) -> Vec<PreAccount> {
let mut pre_accounts = Vec::with_capacity(instruction.accounts.len()); let mut pre_accounts = Vec::with_capacity(instruction.accounts.len());
{ {
@ -1051,7 +1052,7 @@ impl MessageProcessor {
/// Verify there are no outstanding borrows /// Verify there are no outstanding borrows
pub fn verify_account_references( pub fn verify_account_references(
accounts: &[(Pubkey, Rc<RefCell<AccountSharedData>>)], accounts: &[TransactionAccountRefCell],
) -> Result<(), InstructionError> { ) -> Result<(), InstructionError> {
for (_, account) in accounts.iter() { for (_, account) in accounts.iter() {
account account
@ -1067,8 +1068,8 @@ impl MessageProcessor {
message: &Message, message: &Message,
instruction: &CompiledInstruction, instruction: &CompiledInstruction,
pre_accounts: &[PreAccount], pre_accounts: &[PreAccount],
executable_accounts: &[(Pubkey, Rc<RefCell<AccountSharedData>>)], executable_accounts: &[TransactionAccountRefCell],
accounts: &[(Pubkey, Rc<RefCell<AccountSharedData>>)], accounts: &[TransactionAccountRefCell],
rent: &Rent, rent: &Rent,
timings: &mut ExecuteDetailsTimings, timings: &mut ExecuteDetailsTimings,
logger: Rc<RefCell<dyn Logger>>, logger: Rc<RefCell<dyn Logger>>,
@ -1129,7 +1130,7 @@ impl MessageProcessor {
fn verify_and_update( fn verify_and_update(
instruction: &CompiledInstruction, instruction: &CompiledInstruction,
pre_accounts: &mut [PreAccount], pre_accounts: &mut [PreAccount],
accounts: &[(Pubkey, Rc<RefCell<AccountSharedData>>)], accounts: &[TransactionAccountRefCell],
program_id: &Pubkey, program_id: &Pubkey,
rent: &Rent, rent: &Rent,
write_privileges: &[bool], write_privileges: &[bool],
@ -1197,8 +1198,8 @@ impl MessageProcessor {
&self, &self,
message: &Message, message: &Message,
instruction: &CompiledInstruction, instruction: &CompiledInstruction,
executable_accounts: &[(Pubkey, Rc<RefCell<AccountSharedData>>)], executable_accounts: &[TransactionAccountRefCell],
accounts: &[(Pubkey, Rc<RefCell<AccountSharedData>>)], accounts: &[TransactionAccountRefCell],
rent_collector: &RentCollector, rent_collector: &RentCollector,
log_collector: Option<Rc<LogCollector>>, log_collector: Option<Rc<LogCollector>>,
executors: Rc<RefCell<Executors>>, executors: Rc<RefCell<Executors>>,
@ -1214,9 +1215,9 @@ impl MessageProcessor {
// Fixup the special instructions key if present // Fixup the special instructions key if present
// before the account pre-values are taken care of // before the account pre-values are taken care of
if feature_set.is_active(&instructions_sysvar_enabled::id()) { if feature_set.is_active(&instructions_sysvar_enabled::id()) {
for (pubkey, accont) in accounts.iter().take(message.account_keys.len()) { for (pubkey, account) in accounts.iter().take(message.account_keys.len()) {
if instructions::check_id(pubkey) { if instructions::check_id(pubkey) {
let mut mut_account_ref = accont.borrow_mut(); let mut mut_account_ref = account.borrow_mut();
instructions::store_current_index( instructions::store_current_index(
mut_account_ref.data_as_mut_slice(), mut_account_ref.data_as_mut_slice(),
instruction_index as u16, instruction_index as u16,
@ -1298,8 +1299,8 @@ impl MessageProcessor {
pub fn process_message( pub fn process_message(
&self, &self,
message: &Message, message: &Message,
loaders: &[Vec<(Pubkey, Rc<RefCell<AccountSharedData>>)>], loaders: &[Vec<TransactionAccountRefCell>],
accounts: &[(Pubkey, Rc<RefCell<AccountSharedData>>)], accounts: &[TransactionAccountRefCell],
rent_collector: &RentCollector, rent_collector: &RentCollector,
log_collector: Option<Rc<LogCollector>>, log_collector: Option<Rc<LogCollector>>,
executors: Rc<RefCell<Executors>>, executors: Rc<RefCell<Executors>>,
@ -1347,6 +1348,7 @@ mod tests {
super::*, super::*,
solana_sdk::{ solana_sdk::{
account::Account, account::Account,
account::{AccountSharedData, ReadableAccount},
instruction::{AccountMeta, Instruction, InstructionError}, instruction::{AccountMeta, Instruction, InstructionError},
message::Message, message::Message,
native_loader::create_loadable_account_for_test, native_loader::create_loadable_account_for_test,