Skip to content

Conversation

@vicsn
Copy link
Collaborator

@vicsn vicsn commented Oct 23, 2025

Motivation

When investigating the reasons for a rejected transaction, I surfaced these logs:

2025-10-22T16:19:30.218183Z TRACE snarkvm_synthesizer::vm::finalize: Failed to finalize execute tx at10w86clc8666yww60hzmfxekxa8hzfuaxramqac7ydwm54vlp9gzqw882zw - 'constructor' failed to evaluate command (sub r3 r2 into r4;)
2025-10-22T20:58:23.703188Z TRACE snarkvm_synthesizer::vm::finalize: Failed to finalize execute tx at182hjr96y8xdnttupnvfqqh8htur5t7v8ugl8tvxvkt2h06lgwqpsnd69qm - 'finalize' failed on 'credits.aleo/fee_public' - 'constructor' failed to evaluate command (sub r2 r1 into r3;)

Based on the respective commands which failed, it is clear these are 'transfer_public' and 'fee_public' calls which fail due to insufficient balance. Instead of logging these as constructor calls, they should be logged as the respective function call.

Test Plan

Manually reviewed all instances of registers.function_name to catch potential issues.

@vicsn vicsn requested a review from d0cd October 23, 2025 14:38
let constructor_types = stack.get_constructor_types()?.clone();

// Set the FinalizeRegisters function name for constructors.
// Before ConsensusVersion::V12, this was wrongly using the program id as function name.
Copy link
Collaborator

@d0cd d0cd Oct 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it "wrong" to use the program ID name vs. hard-coding constructor? Is there a security issue or is this purely for logging?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong was maybe strongly worded, but we are setting a program_id into a variable called function_name, which is semantically wrong. It's a piece of the code few people looked at, so added some documentation: f644a54

// Set the FinalizeRegisters function name for constructors.
// Before ConsensusVersion::V12, this was wrongly using the program id as function name.
let consensus_version = N::CONSENSUS_VERSION(state.block_height())?;
let identifier = if consensus_version >= ConsensusVersion::V12 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the purpose of this change is to improve the log message, can you pass in a flag to finalize_command_expect_await and set the message accordingly?

This avoids the permanent "overhead" of tracking this to a ConsensusVersion

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, it adds complexity and risks a fork. Changed it to just a logging adjustment: 7d92c1e

@vicsn vicsn force-pushed the fix_finalize_print branch from 895b850 to 7d92c1e Compare October 24, 2025 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants