Pre-construct cpi instruction recorders before message processing (#12467)
This commit is contained in:
parent
b7d3ddbfe3
commit
1c970bb39f
|
@ -2009,11 +2009,15 @@ impl Bank {
|
||||||
let (account_refcells, loader_refcells) =
|
let (account_refcells, loader_refcells) =
|
||||||
Self::accounts_to_refcells(accounts, loaders);
|
Self::accounts_to_refcells(accounts, loaders);
|
||||||
|
|
||||||
let mut instruction_recorders = if enable_cpi_recording {
|
let instruction_recorders = if enable_cpi_recording {
|
||||||
Some(Vec::new())
|
Some(vec![
|
||||||
|
InstructionRecorder::default();
|
||||||
|
tx.message.instructions.len()
|
||||||
|
])
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
let process_result = self.message_processor.process_message(
|
let process_result = self.message_processor.process_message(
|
||||||
tx.message(),
|
tx.message(),
|
||||||
&loader_refcells,
|
&loader_refcells,
|
||||||
|
@ -2021,7 +2025,7 @@ impl Bank {
|
||||||
&self.rent_collector,
|
&self.rent_collector,
|
||||||
log_collector.clone(),
|
log_collector.clone(),
|
||||||
executors.clone(),
|
executors.clone(),
|
||||||
instruction_recorders.as_mut(),
|
instruction_recorders.as_deref(),
|
||||||
self.cluster_type(),
|
self.cluster_type(),
|
||||||
self.epoch(),
|
self.epoch(),
|
||||||
);
|
);
|
||||||
|
|
|
@ -734,16 +734,14 @@ impl MessageProcessor {
|
||||||
rent_collector: &RentCollector,
|
rent_collector: &RentCollector,
|
||||||
log_collector: Option<Rc<LogCollector>>,
|
log_collector: Option<Rc<LogCollector>>,
|
||||||
executors: Rc<RefCell<Executors>>,
|
executors: Rc<RefCell<Executors>>,
|
||||||
mut instruction_recorders: Option<&mut Vec<InstructionRecorder>>,
|
instruction_recorders: Option<&[InstructionRecorder]>,
|
||||||
cluster_type: ClusterType,
|
cluster_type: ClusterType,
|
||||||
epoch: Epoch,
|
epoch: Epoch,
|
||||||
) -> Result<(), TransactionError> {
|
) -> Result<(), TransactionError> {
|
||||||
for (instruction_index, instruction) in message.instructions.iter().enumerate() {
|
for (instruction_index, instruction) in message.instructions.iter().enumerate() {
|
||||||
let instruction_recorder = instruction_recorders.as_mut().map(|recorders| {
|
let instruction_recorder = instruction_recorders
|
||||||
let instruction_recorder = InstructionRecorder::default();
|
.as_ref()
|
||||||
recorders.push(instruction_recorder.clone());
|
.map(|recorders| recorders[instruction_index].clone());
|
||||||
instruction_recorder
|
|
||||||
});
|
|
||||||
self.execute_instruction(
|
self.execute_instruction(
|
||||||
message,
|
message,
|
||||||
instruction,
|
instruction,
|
||||||
|
|
Loading…
Reference in New Issue