Skip to content

Commit

Permalink
feat: deplete compute meter for vm errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jstarry committed Nov 22, 2024
1 parent eeb52d2 commit c5cad1b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions programs/bpf_loader/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1473,6 +1473,25 @@ pub fn execute<'a, 'b: 'a>(
Err(Box::new(error) as Box<dyn std::error::Error>)
}
ProgramResult::Err(mut error) => {
if invoke_context
.get_feature_set()
.is_active(&solana_feature_set::apply_cost_tracker_during_replay::id())
{
if !matches!(error, EbpfError::SyscallError(_)) {
// when an exception is thrown during the execution of a
// Basic Block (e.g., a null memory dereference or other
// faults), determining the exact number of CUs consumed
// up to the point of failure requires additional effort
// and is unnecessary since these cases are rare.
//
// In order to simplify CU tracking, simply consume all
// remaining compute units so that the block cost
// tracker uses the full requested compute unit cost for
// this failed transaction.
invoke_context.consume(invoke_context.get_remaining());
}
}

if direct_mapping {
if let EbpfError::AccessViolation(
AccessType::Store,
Expand Down

0 comments on commit c5cad1b

Please sign in to comment.