diff --git a/frame/evm/src/runner/stack.rs b/frame/evm/src/runner/stack.rs index 387ec78163..7b645f6bf7 100644 --- a/frame/evm/src/runner/stack.rs +++ b/frame/evm/src/runner/stack.rs @@ -982,18 +982,18 @@ where .try_record_proof_size_or_fail(ACCOUNT_CODES_METADATA_PROOF_SIZE)?; if let Some(meta) = >::get(address) { weight_info.try_record_proof_size_or_fail(meta.size)?; - } else { - if let Some(remaining_proof_size) = weight_info.remaining_proof_size() { - let pre_size = remaining_proof_size.min(size_limit); - weight_info.try_record_proof_size_or_fail(pre_size)?; - - let actual_size = Pallet::::account_code_metadata(address).size; - if actual_size > pre_size { - return Err(ExitError::OutOfGas); - } - // Refund unused proof size - weight_info.refund_proof_size(pre_size.saturating_sub(actual_size)); + } else if let Some(remaining_proof_size) = + weight_info.remaining_proof_size() + { + let pre_size = remaining_proof_size.min(size_limit); + weight_info.try_record_proof_size_or_fail(pre_size)?; + + let actual_size = Pallet::::account_code_metadata(address).size; + if actual_size > pre_size { + return Err(ExitError::OutOfGas); } + // Refund unused proof size + weight_info.refund_proof_size(pre_size.saturating_sub(actual_size)); } recorded.account_codes.push(address); } @@ -1062,19 +1062,18 @@ where if let Some(meta) = >::get(address) { weight_info.try_record_proof_size_or_fail(meta.size)?; - } else { - if let Some(remaining_proof_size) = weight_info.remaining_proof_size() { - let pre_size = remaining_proof_size.min(size_limit); - weight_info.try_record_proof_size_or_fail(pre_size)?; + } else if let Some(remaining_proof_size) = weight_info.remaining_proof_size() { + let pre_size = remaining_proof_size.min(size_limit); + weight_info.try_record_proof_size_or_fail(pre_size)?; - let actual_size = Pallet::::account_code_metadata(address).size; - if actual_size > pre_size { - return Err(ExitError::OutOfGas); - } - // Refund unused proof size - weight_info.refund_proof_size(pre_size.saturating_sub(actual_size)); + let actual_size = Pallet::::account_code_metadata(address).size; + if actual_size > pre_size { + return Err(ExitError::OutOfGas); } + // Refund unused proof size + weight_info.refund_proof_size(pre_size.saturating_sub(actual_size)); } + Ok(()) };