@@ -244,6 +244,9 @@ fn finalize_constructor<N: Network, P: FinalizeStorage<N>>(
244244 // Initialize the finalize registers.
245245 let mut registers = FinalizeRegisters :: new ( state, transition_id, * program_id. name ( ) , constructor_types, nonce) ;
246246
247+ // Determine the scope name.
248+ let scope_name = Identifier :: < N > :: from_str ( "constructor" ) ?;
249+
247250 // Initialize a counter for the commands.
248251 let mut counter = 0 ;
249252
@@ -264,6 +267,7 @@ fn finalize_constructor<N: Network, P: FinalizeStorage<N>>(
264267 command,
265268 & mut counter,
266269 & mut finalize_operations,
270+ & scope_name,
267271 ) ?,
268272 } ;
269273 }
@@ -325,6 +329,8 @@ fn finalize_transition<N: Network, P: FinalizeStorage<N>>(
325329 registers. function_name( )
326330 )
327331 } ;
332+ // Determine the scope name.
333+ let scope_name = * registers. function_name ( ) ;
328334 // Evaluate the commands.
329335 while counter < finalize. commands ( ) . len ( ) {
330336 // Retrieve the command.
@@ -406,6 +412,7 @@ fn finalize_transition<N: Network, P: FinalizeStorage<N>>(
406412 command,
407413 & mut counter,
408414 & mut finalize_operations,
415+ & scope_name,
409416 ) ?,
410417 } ;
411418 }
@@ -441,7 +448,7 @@ struct FinalizeState<N: Network> {
441448 awaited : HashSet < Register < N > > ,
442449}
443450
444- // A helper function to initialize the finalize state.
451+ // A helper function to initialize the finalize state for transitions (not constructors) .
445452fn initialize_finalize_state < N : Network > (
446453 state : FinalizeGlobalState ,
447454 future : & Future < N > ,
@@ -492,6 +499,7 @@ fn finalize_command_except_await<N: Network>(
492499 command : & Command < N > ,
493500 counter : & mut usize ,
494501 finalize_operations : & mut Vec < FinalizeOperation < N > > ,
502+ scope_name : & Identifier < N > ,
495503) -> Result < ( ) > {
496504 // Finalize the command.
497505 match & command {
@@ -502,9 +510,9 @@ fn finalize_command_except_await<N: Network>(
502510 * counter = new_counter;
503511 }
504512 // If the evaluation fails, bail and return the error.
505- Ok ( Err ( error) ) => bail ! ( "'constructor ' failed to evaluate command ({command}): {error}" ) ,
513+ Ok ( Err ( error) ) => bail ! ( "'{scope_name} ' failed to evaluate command ({command}): {error}" ) ,
506514 // If the evaluation fails, bail and return the error.
507- Err ( _) => bail ! ( "'constructor ' failed to evaluate command ({command})" ) ,
515+ Err ( _) => bail ! ( "'{scope_name} ' failed to evaluate command ({command})" ) ,
508516 }
509517 }
510518 Command :: BranchNeq ( branch_neq) => {
@@ -514,9 +522,9 @@ fn finalize_command_except_await<N: Network>(
514522 * counter = new_counter;
515523 }
516524 // If the evaluation fails, bail and return the error.
517- Ok ( Err ( error) ) => bail ! ( "'constructor ' failed to evaluate command ({command}): {error}" ) ,
525+ Ok ( Err ( error) ) => bail ! ( "'{scope_name} ' failed to evaluate command ({command}): {error}" ) ,
518526 // If the evaluation fails, bail and return the error.
519- Err ( _) => bail ! ( "'constructor ' failed to evaluate command ({command})" ) ,
527+ Err ( _) => bail ! ( "'{scope_name} ' failed to evaluate command ({command})" ) ,
520528 }
521529 }
522530 Command :: Await ( _) => {
@@ -530,9 +538,9 @@ fn finalize_command_except_await<N: Network>(
530538 // If the evaluation succeeds with no operation, continue.
531539 Ok ( Ok ( None ) ) => { }
532540 // If the evaluation fails, bail and return the error.
533- Ok ( Err ( error) ) => bail ! ( "'constructor ' failed to evaluate command ({command}): {error}" ) ,
541+ Ok ( Err ( error) ) => bail ! ( "'{scope_name} ' failed to evaluate command ({command}): {error}" ) ,
534542 // If the evaluation fails, bail and return the error.
535- Err ( _) => bail ! ( "'constructor ' failed to evaluate command ({command})" ) ,
543+ Err ( _) => bail ! ( "'{scope_name} ' failed to evaluate command ({command})" ) ,
536544 }
537545 * counter += 1 ;
538546 }
0 commit comments