Repository: aptos-labs/aptos-core
File: third_party/move/move-vm/runtime/src/interpreter.rs (Rust)

Code before:

                        let error_code = interpreter.operand_stack.pop_as::<u64>()?;

                        if is_tracing_for!(TraceCategory::Abort(error_code)) {
                            let mut str = String::new();
                            interpreter.debug_print_stack_trace(
                                &mut str,
                                interpreter.loader.runtime_environment(),
                            )?;
                            eprintln!(
                                "trace abort_msg({}, {}): {}",
                                error_code, error_message, str
                            );
                        }
                        let error = PartialVMError::new(StatusCode::ABORTED)
                            .with_sub_status(error_code)
                            .with_message(error_message);

                        // Before returning an abort error, ensure the instruction is recorded in
                        // the trace, so the trace is full.
                        trace_recorder.record_successful_instruction(instruction);
                        return Err(error);
                    },
                    Instruction::Eq => {
                        let lhs = interpreter.operand_stack.pop()?;
                        let rhs = interpreter.operand_stack.pop()?;
                        gas_meter.charge_eq(&lhs, &rhs)?;
                        interpreter
                            .operand_stack
                            .push(Value::bool(lhs.equals(&rhs)?))?;
                    },
                    Instruction::Neq => {
                        let lhs = interpreter.operand_stack.pop()?;
                        let rhs = interpreter.operand_stack.pop()?;
                        gas_meter.charge_neq(&lhs, &rhs)?;
                        interpreter
                            .operand_stack
                            .push(Value::bool(!lhs.equals(&rhs)?))?;
                    },
                    Instruction::MutBorrowGlobal(sd_idx) | Instruction::ImmBorrowGlobal(sd_idx) => {
                        let is_mut = matches!(instruction, Instruction::MutBorrowGlobal(_));
                        let addr = interpreter.operand_stack.pop_as::<AccountAddress>()?;
                        let ty = self.get_struct_ty(*sd_idx);
                        interpreter.borrow_global(
                            is_mut,
                            false,
                            data_cache,
                            gas_meter,
                            traversal_context,
                            addr,
                            &ty,

Review comment (suggestion):
Previously, the message here was
```
format!("{} at offset {}", self.function.name_as_pretty_string(), self.pc)
```

I removed it in order to distinguish between aborts that include an explicit message and those that do not. This should be fine, since the message was discarded anyway when converting into an `ExecutionStatus`.

No information is lost: the `VMError` already records both the offset and abort location (see [abort.exp](https://github.com/aptos-labs/aptos-core/pull/18316/changes#diff-86fa0b16bfdc51af94f3fc5b706e1a8bdc2987f9e31e320cfc3f98f1e8450471)).

Code after:
                    },
                    Instruction::Le => {
                        gas_meter.charge_simple_instr(S::Le)?;
                        interpreter.binop_rel(Value::le)?;
                    },
                    Instruction::Ge => {
                        gas_meter.charge_simple_instr(S::Ge)?;
                        interpreter.binop_rel(Value::ge)?;
                    },
                    Instruction::Abort => {
                        gas_meter.charge_simple_instr(S::Abort)?;
                        let error_code = interpreter.operand_stack.pop_as::<u64>()?;
                        if is_tracing_for!(TraceCategory::Abort(error_code)) {
                            let mut str = String::new();
                            interpreter.debug_print_stack_trace(
                                &mut str,
                                interpreter.loader.runtime_environment(),
                            )?;
                            eprintln!("trace abort({}): {}", error_code, str);
                        }

                        // Important: do not attach a message here.
                        // We rely on the presence of an error message to distinguish
                        // aborts with explicit messages (see below) from those without.
                        let error =
                            PartialVMError::new(StatusCode::ABORTED).with_sub_status(error_code);

                        // Before returning an abort error, ensure the instruction is recorded in
                        // the trace, so the trace is full.
                        trace_recorder.record_successful_instruction(instruction);
                        return Err(error);
                    },
                    Instruction::AbortMsg => {
                        gas_meter.charge_simple_instr(S::Abort)?;

                        let vec = interpreter.operand_stack.pop_as::<Vector>()?;
                        let bytes = vec.to_vec_u8()?;
                        // TODO(aborts): Add a test that triggers this error.
                        let error_message = String::from_utf8(bytes).map_err(|err| {
                            PartialVMError::new(StatusCode::INVALID_ABORT_MESSAGE)
                                .with_message(format!("Invalid UTF-8 string: {err}"))
                        })?;

                        let error_code = interpreter.operand_stack.pop_as::<u64>()?;

                        if is_tracing_for!(TraceCategory::Abort(error_code)) {
                            let mut str = String::new();
                            interpreter.debug_print_stack_trace(
                                &mut str,
                                interpreter.loader.runtime_environment(),
                            )?;