Count compute units even when transaction errors (#22182)
This commit is contained in:
@ -142,6 +142,20 @@ impl CostModel {
|
||||
self.instruction_execution_cost_table.get_cost_table()
|
||||
}
|
||||
|
||||
pub fn find_instruction_cost(&self, program_key: &Pubkey) -> u64 {
|
||||
match self.instruction_execution_cost_table.get_cost(program_key) {
|
||||
Some(cost) => *cost,
|
||||
None => {
|
||||
let default_value = self.instruction_execution_cost_table.get_mode();
|
||||
debug!(
|
||||
"Program key {:?} does not have assigned cost, using mode {}",
|
||||
program_key, default_value
|
||||
);
|
||||
default_value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn get_signature_cost(&self, transaction: &SanitizedTransaction) -> u64 {
|
||||
transaction.signatures().len() as u64 * SIGNATURE_COST
|
||||
}
|
||||
@ -188,20 +202,6 @@ impl CostModel {
|
||||
cost
|
||||
}
|
||||
|
||||
fn find_instruction_cost(&self, program_key: &Pubkey) -> u64 {
|
||||
match self.instruction_execution_cost_table.get_cost(program_key) {
|
||||
Some(cost) => *cost,
|
||||
None => {
|
||||
let default_value = self.instruction_execution_cost_table.get_mode();
|
||||
debug!(
|
||||
"Program key {:?} does not have assigned cost, using mode {}",
|
||||
program_key, default_value
|
||||
);
|
||||
default_value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn calculate_account_data_size_on_deserialized_system_instruction(
|
||||
instruction: SystemInstruction,
|
||||
) -> u64 {
|
||||
|
@ -3,7 +3,7 @@ use {
|
||||
solana_measure::measure::Measure,
|
||||
solana_program_runtime::{
|
||||
instruction_recorder::InstructionRecorder,
|
||||
invoke_context::{BuiltinProgram, Executors, InvokeContext},
|
||||
invoke_context::{BuiltinProgram, Executors, InvokeContext, ProcessInstructionResult},
|
||||
log_collector::LogCollector,
|
||||
timings::ExecuteDetailsTimings,
|
||||
},
|
||||
@ -128,21 +128,25 @@ impl MessageProcessor {
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
let mut time = Measure::start("execute_instruction");
|
||||
let compute_meter_consumption = invoke_context
|
||||
.process_instruction(
|
||||
&instruction.data,
|
||||
&instruction_accounts,
|
||||
None,
|
||||
program_indices,
|
||||
)
|
||||
.map_err(|err| TransactionError::InstructionError(instruction_index as u8, err))?;
|
||||
let ProcessInstructionResult {
|
||||
compute_units_consumed,
|
||||
result,
|
||||
} = invoke_context.process_instruction(
|
||||
&instruction.data,
|
||||
&instruction_accounts,
|
||||
None,
|
||||
program_indices,
|
||||
);
|
||||
time.stop();
|
||||
timings.accumulate_program(
|
||||
instruction.program_id(&message.account_keys),
|
||||
time.as_us(),
|
||||
compute_meter_consumption,
|
||||
compute_units_consumed,
|
||||
result.is_err(),
|
||||
);
|
||||
timings.accumulate(&invoke_context.timings);
|
||||
result
|
||||
.map_err(|err| TransactionError::InstructionError(instruction_index as u8, err))?;
|
||||
}
|
||||
Ok(ProcessedMessageInfo {
|
||||
accounts_data_len: invoke_context.get_accounts_data_meter().current(),
|
||||
|
Reference in New Issue
Block a user