Move type alias and use it more broadly (#21763)
This commit is contained in:
@ -25,6 +25,9 @@ use {
|
|||||||
std::{cell::RefCell, collections::HashMap, fmt::Debug, rc::Rc, sync::Arc},
|
std::{cell::RefCell, collections::HashMap, fmt::Debug, rc::Rc, sync::Arc},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub type TransactionAccountRefCell = (Pubkey, Rc<RefCell<AccountSharedData>>);
|
||||||
|
pub type TransactionAccountRefCells = Vec<TransactionAccountRefCell>;
|
||||||
|
|
||||||
pub type ProcessInstructionWithContext =
|
pub type ProcessInstructionWithContext =
|
||||||
fn(usize, &[u8], &mut InvokeContext) -> Result<(), InstructionError>;
|
fn(usize, &[u8], &mut InvokeContext) -> Result<(), InstructionError>;
|
||||||
|
|
||||||
@ -138,7 +141,7 @@ pub struct InvokeContext<'a> {
|
|||||||
invoke_stack: Vec<StackFrame<'a>>,
|
invoke_stack: Vec<StackFrame<'a>>,
|
||||||
rent: Rent,
|
rent: Rent,
|
||||||
pre_accounts: Vec<PreAccount>,
|
pre_accounts: Vec<PreAccount>,
|
||||||
accounts: &'a [(Pubkey, Rc<RefCell<AccountSharedData>>)],
|
accounts: &'a [TransactionAccountRefCell],
|
||||||
builtin_programs: &'a [BuiltinProgram],
|
builtin_programs: &'a [BuiltinProgram],
|
||||||
pub sysvars: &'a [(Pubkey, Vec<u8>)],
|
pub sysvars: &'a [(Pubkey, Vec<u8>)],
|
||||||
log_collector: Option<Rc<RefCell<LogCollector>>>,
|
log_collector: Option<Rc<RefCell<LogCollector>>>,
|
||||||
@ -158,7 +161,7 @@ impl<'a> InvokeContext<'a> {
|
|||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn new(
|
pub fn new(
|
||||||
rent: Rent,
|
rent: Rent,
|
||||||
accounts: &'a [(Pubkey, Rc<RefCell<AccountSharedData>>)],
|
accounts: &'a [TransactionAccountRefCell],
|
||||||
builtin_programs: &'a [BuiltinProgram],
|
builtin_programs: &'a [BuiltinProgram],
|
||||||
sysvars: &'a [(Pubkey, Vec<u8>)],
|
sysvars: &'a [(Pubkey, Vec<u8>)],
|
||||||
log_collector: Option<Rc<RefCell<LogCollector>>>,
|
log_collector: Option<Rc<RefCell<LogCollector>>>,
|
||||||
@ -190,7 +193,7 @@ impl<'a> InvokeContext<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_mock(
|
pub fn new_mock(
|
||||||
accounts: &'a [(Pubkey, Rc<RefCell<AccountSharedData>>)],
|
accounts: &'a [TransactionAccountRefCell],
|
||||||
builtin_programs: &'a [BuiltinProgram],
|
builtin_programs: &'a [BuiltinProgram],
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self::new(
|
Self::new(
|
||||||
@ -828,7 +831,7 @@ impl<'a> InvokeContext<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct MockInvokeContextPreparation {
|
pub struct MockInvokeContextPreparation {
|
||||||
pub accounts: Vec<(Pubkey, Rc<RefCell<AccountSharedData>>)>,
|
pub accounts: TransactionAccountRefCells,
|
||||||
pub message: Message,
|
pub message: Message,
|
||||||
pub account_indices: Vec<usize>,
|
pub account_indices: Vec<usize>,
|
||||||
}
|
}
|
||||||
@ -839,10 +842,7 @@ pub fn prepare_mock_invoke_context(
|
|||||||
keyed_accounts: &[(bool, bool, Pubkey, Rc<RefCell<AccountSharedData>>)],
|
keyed_accounts: &[(bool, bool, Pubkey, Rc<RefCell<AccountSharedData>>)],
|
||||||
) -> MockInvokeContextPreparation {
|
) -> MockInvokeContextPreparation {
|
||||||
#[allow(clippy::type_complexity)]
|
#[allow(clippy::type_complexity)]
|
||||||
let (accounts, mut metas): (
|
let (accounts, mut metas): (TransactionAccountRefCells, Vec<AccountMeta>) = keyed_accounts
|
||||||
Vec<(Pubkey, Rc<RefCell<AccountSharedData>>)>,
|
|
||||||
Vec<AccountMeta>,
|
|
||||||
) = keyed_accounts
|
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(is_signer, is_writable, pubkey, account)| {
|
.map(|(is_signer, is_writable, pubkey, account)| {
|
||||||
(
|
(
|
||||||
|
@ -74,7 +74,10 @@ use {
|
|||||||
solana_metrics::{inc_new_counter_debug, inc_new_counter_info},
|
solana_metrics::{inc_new_counter_debug, inc_new_counter_info},
|
||||||
solana_program_runtime::{
|
solana_program_runtime::{
|
||||||
instruction_recorder::InstructionRecorder,
|
instruction_recorder::InstructionRecorder,
|
||||||
invoke_context::{BuiltinProgram, Executor, Executors, ProcessInstructionWithContext},
|
invoke_context::{
|
||||||
|
BuiltinProgram, Executor, Executors, ProcessInstructionWithContext,
|
||||||
|
TransactionAccountRefCells,
|
||||||
|
},
|
||||||
log_collector::LogCollector,
|
log_collector::LogCollector,
|
||||||
timings::ExecuteDetailsTimings,
|
timings::ExecuteDetailsTimings,
|
||||||
},
|
},
|
||||||
@ -236,8 +239,6 @@ impl ExecuteTimings {
|
|||||||
type BankStatusCache = StatusCache<Result<()>>;
|
type BankStatusCache = StatusCache<Result<()>>;
|
||||||
#[frozen_abi(digest = "32EjVUc6shHHVPpsnBAVfyBziMgyFzH8qxisLwmwwdS1")]
|
#[frozen_abi(digest = "32EjVUc6shHHVPpsnBAVfyBziMgyFzH8qxisLwmwwdS1")]
|
||||||
pub type BankSlotDelta = SlotDelta<Result<()>>;
|
pub type BankSlotDelta = SlotDelta<Result<()>>;
|
||||||
pub(crate) type TransactionAccountRefCell = (Pubkey, Rc<RefCell<AccountSharedData>>);
|
|
||||||
type TransactionAccountRefCells = 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
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
use {
|
use {
|
||||||
crate::bank::TransactionAccountRefCell,
|
|
||||||
serde::{Deserialize, Serialize},
|
serde::{Deserialize, Serialize},
|
||||||
solana_measure::measure::Measure,
|
solana_measure::measure::Measure,
|
||||||
solana_program_runtime::{
|
solana_program_runtime::{
|
||||||
instruction_recorder::InstructionRecorder,
|
instruction_recorder::InstructionRecorder,
|
||||||
invoke_context::{BuiltinProgram, Executors, InvokeContext},
|
invoke_context::{BuiltinProgram, Executors, InvokeContext, TransactionAccountRefCell},
|
||||||
log_collector::LogCollector,
|
log_collector::LogCollector,
|
||||||
timings::ExecuteDetailsTimings,
|
timings::ExecuteDetailsTimings,
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user