@@ -223,7 +223,6 @@ fn finalize_constructor<N: Network, P: FinalizeStorage<N>>(
223223 transition_id : N :: TransitionID ,
224224) -> Result < Vec < FinalizeOperation < N > > > {
225225 // Retrieve the program ID.
226- let program_id = stack. program_id ( ) ;
227226 dev_println ! ( "Finalizing constructor for {}..." , stack. program_id( ) ) ;
228227
229228 // Initialize a list for finalize operations.
@@ -241,8 +240,10 @@ fn finalize_constructor<N: Network, P: FinalizeStorage<N>>(
241240 // Get the constructor types.
242241 let constructor_types = stack. get_constructor_types ( ) ?. clone ( ) ;
243242
243+ let identifier = Identifier :: < N > :: from_str ( "constructor" ) ?;
244+
244245 // Initialize the finalize registers.
245- let mut registers = FinalizeRegisters :: new ( state, transition_id, * program_id . name ( ) , constructor_types, nonce) ;
246+ let mut registers = FinalizeRegisters :: new ( state, transition_id, identifier , constructor_types, nonce) ;
246247
247248 // Initialize a counter for the commands.
248249 let mut counter = 0 ;
@@ -441,7 +442,7 @@ struct FinalizeState<N: Network> {
441442 awaited : HashSet < Register < N > > ,
442443}
443444
444- // A helper function to initialize the finalize state.
445+ // A helper function to initialize the finalize state for transitions (not constructors) .
445446fn initialize_finalize_state < N : Network > (
446447 state : FinalizeGlobalState ,
447448 future : & Future < N > ,
@@ -493,6 +494,7 @@ fn finalize_command_except_await<N: Network>(
493494 counter : & mut usize ,
494495 finalize_operations : & mut Vec < FinalizeOperation < N > > ,
495496) -> Result < ( ) > {
497+ let function_name = * registers. function_name ( ) ;
496498 // Finalize the command.
497499 match & command {
498500 Command :: BranchEq ( branch_eq) => {
@@ -502,9 +504,9 @@ fn finalize_command_except_await<N: Network>(
502504 * counter = new_counter;
503505 }
504506 // If the evaluation fails, bail and return the error.
505- Ok ( Err ( error) ) => bail ! ( "'constructor ' failed to evaluate command ({command}): {error}" ) ,
507+ Ok ( Err ( error) ) => bail ! ( "'{function_name} ' failed to evaluate command ({command}): {error}" ) ,
506508 // If the evaluation fails, bail and return the error.
507- Err ( _) => bail ! ( "'constructor ' failed to evaluate command ({command})" ) ,
509+ Err ( _) => bail ! ( "'{function_name} ' failed to evaluate command ({command})" ) ,
508510 }
509511 }
510512 Command :: BranchNeq ( branch_neq) => {
@@ -514,9 +516,9 @@ fn finalize_command_except_await<N: Network>(
514516 * counter = new_counter;
515517 }
516518 // If the evaluation fails, bail and return the error.
517- Ok ( Err ( error) ) => bail ! ( "'constructor ' failed to evaluate command ({command}): {error}" ) ,
519+ Ok ( Err ( error) ) => bail ! ( "'{function_name} ' failed to evaluate command ({command}): {error}" ) ,
518520 // If the evaluation fails, bail and return the error.
519- Err ( _) => bail ! ( "'constructor ' failed to evaluate command ({command})" ) ,
521+ Err ( _) => bail ! ( "'{function_name} ' failed to evaluate command ({command})" ) ,
520522 }
521523 }
522524 Command :: Await ( _) => {
@@ -530,9 +532,9 @@ fn finalize_command_except_await<N: Network>(
530532 // If the evaluation succeeds with no operation, continue.
531533 Ok ( Ok ( None ) ) => { }
532534 // If the evaluation fails, bail and return the error.
533- Ok ( Err ( error) ) => bail ! ( "'constructor ' failed to evaluate command ({command}): {error}" ) ,
535+ Ok ( Err ( error) ) => bail ! ( "'{function_name} ' failed to evaluate command ({command}): {error}" ) ,
534536 // If the evaluation fails, bail and return the error.
535- Err ( _) => bail ! ( "'constructor ' failed to evaluate command ({command})" ) ,
537+ Err ( _) => bail ! ( "'{function_name} ' failed to evaluate command ({command})" ) ,
536538 }
537539 * counter += 1 ;
538540 }
0 commit comments