@@ -65,7 +65,11 @@ from starkware.starknet.core.os.execution.execute_transaction_utils import (
6565 run_validate,
6666 update_class_hash_in_execution_context,
6767)
68- from starkware.starknet.core.os.execution.execution_constraints import check_n_txs, check_tx_type
68+ from starkware.starknet.core.os.execution.execution_constraints import (
69+ check_n_txs,
70+ check_sender_address,
71+ check_tx_type,
72+ )
6973from starkware.starknet.core.os.execution.revert import init_revert_log
7074from starkware.starknet.core.os.output import (
7175 MessageToL2Header,
@@ -212,29 +216,38 @@ func execute_transactions_inner{
212216
213217 check_tx_type(tx_type=tx_type);
214218
219+ local sender_address: felt ;
215220 if (tx_type == 'INVOKE_FUNCTION' ) {
216221 // Handle the invoke-function transaction.
217- execute_invoke_function_transaction(block_context=block_context);
218- %{ ExitTx %}
219- return execute_transactions_inner(block_context=block_context, n_txs=n_txs - 1 );
220- }
221- if (tx_type == 'L1_HANDLER' ) {
222- // Handle the L1-handler transaction.
223- execute_l1_handler_transaction(block_context=block_context);
222+ let (tx_sender_address) = execute_invoke_function_transaction(block_context=block_context);
224223 %{ ExitTx %}
225- return execute_transactions_inner(block_context=block_context, n_txs=n_txs - 1 );
226- }
227- if (tx_type == 'DEPLOY_ACCOUNT' ) {
228- // Handle the deploy-account transaction.
229- execute_deploy_account_transaction(block_context=block_context);
230- %{ ExitTx %}
231- return execute_transactions_inner(block_context=block_context, n_txs=n_txs - 1 );
224+ assert sender_address = tx_sender_address;
225+ } else {
226+ if (tx_type == 'L1_HANDLER' ) {
227+ // Handle the L1-handler transaction.
228+ let (tx_sender_address) = execute_l1_handler_transaction(block_context=block_context);
229+ %{ ExitTx %}
230+ assert sender_address = tx_sender_address;
231+ } else {
232+ if (tx_type == 'DEPLOY_ACCOUNT' ) {
233+ // Handle the deploy-account transaction.
234+ let (tx_sender_address) = execute_deploy_account_transaction(
235+ block_context=block_context
236+ );
237+ %{ ExitTx %}
238+ assert sender_address = tx_sender_address;
239+ } else {
240+ assert tx_type = 'DECLARE' ;
241+ // Handle the declare transaction.
242+ let (tx_sender_address) = execute_declare_transaction(block_context=block_context);
243+ %{ ExitTx %}
244+ assert sender_address = tx_sender_address;
245+ }
246+ }
232247 }
233248
234- assert tx_type = 'DECLARE' ;
235- // Handle the declare transaction.
236- execute_declare_transaction(block_context=block_context);
237- %{ ExitTx %}
249+ check_sender_address(sender_address=sender_address, block_context=block_context);
250+
238251 return execute_transactions_inner(block_context=block_context, n_txs=n_txs - 1 );
239252}
240253
@@ -408,13 +421,16 @@ func fill_account_tx_info{range_check_ptr}(
408421//
409422// Arguments:
410423// block_context - a global context that is fixed throughout the block.
424+ //
425+ // Returns:
426+ // sender_address - the address of the transaction sender.
411427func execute_invoke_function_transaction {
412428 range_check_ptr,
413429 builtin_ptrs: BuiltinPointers*,
414430 contract_state_changes: DictAccess*,
415431 contract_class_changes: DictAccess*,
416432 outputs: OsCarriedOutputs*,
417- } (block_context: BlockContext*) {
433+ } (block_context: BlockContext*) -> (sender_address: felt ) {
418434 alloc_locals ;
419435
420436 // TODO(Yoni): consider not sharing this code with L1 handler.
@@ -424,13 +440,14 @@ func execute_invoke_function_transaction{
424440 entry_point_selector=EXECUTE_ENTRY_POINT_SELECTOR,
425441 );
426442 local tx_execution_info: ExecutionInfo* = tx_execution_context.execution_info;
443+ let sender_address = tx_execution_info.contract_address;
427444
428445 // Guess transaction fields.
429446 // The version validation is done in `compute_invoke_transaction_hash()`.
430447 let common_tx_fields = get_account_tx_common_fields(
431448 block_context=block_context,
432449 tx_hash_prefix=INVOKE_HASH_PREFIX,
433- sender_address=tx_execution_info.contract_address ,
450+ sender_address=sender_address ,
434451 );
435452 local account_deployment_data_size;
436453 local account_deployment_data: felt *;
@@ -513,7 +530,7 @@ func execute_invoke_function_transaction{
513530
514531 %{ EndTx %}
515532
516- return ();
533+ return (sender_address=sender_address );
517534}
518535
519536// Executes an L1-handler transaction.
@@ -528,7 +545,7 @@ func execute_l1_handler_transaction{
528545 contract_state_changes: DictAccess*,
529546 contract_class_changes: DictAccess*,
530547 outputs: OsCarriedOutputs*,
531- } (block_context: BlockContext*) {
548+ } (block_context: BlockContext*) -> (sender_address: felt ) {
532549 alloc_locals ;
533550
534551 %{ StartTx %}
@@ -537,7 +554,7 @@ func execute_l1_handler_transaction{
537554 // Skip the execution step for reverted transaction.
538555 if (is_reverted != FALSE) {
539556 %{ EndTx %}
540- return ();
557+ return (sender_address= 0 );
541558 }
542559
543560 // TODO(Yoni): currently, the contract state is not fetched for reverted L1 handlers.
@@ -599,7 +616,7 @@ func execute_l1_handler_transaction{
599616 );
600617
601618 %{ EndTx %}
602- return ();
619+ return (sender_address= 0 );
603620}
604621
605622// Guess the execution context of an invoke transaction (either invoke function or L1 handler).
@@ -718,13 +735,15 @@ func prepare_constructor_execution_context{range_check_ptr, builtin_ptrs: Builti
718735 );
719736}
720737
738+ // Returns:
739+ // sender_address - the address of the transaction sender.
721740func execute_deploy_account_transaction {
722741 range_check_ptr,
723742 builtin_ptrs: BuiltinPointers*,
724743 contract_state_changes: DictAccess*,
725744 contract_class_changes: DictAccess*,
726745 outputs: OsCarriedOutputs*,
727- } (block_context: BlockContext*) {
746+ } (block_context: BlockContext*) -> (sender_address: felt ) {
728747 alloc_locals ;
729748
730749 // Calculate address and prepare constructor execution context.
@@ -838,23 +857,25 @@ func execute_deploy_account_transaction{
838857 charge_fee(block_context=block_context, tx_execution_context=validate_deploy_execution_context);
839858
840859 %{ EndTx %}
841- return ();
860+ return (sender_address=sender_address );
842861}
843862
863+ // Returns:
864+ // sender_address - the address of the transaction sender.
844865func execute_declare_transaction {
845866 range_check_ptr,
846867 builtin_ptrs: BuiltinPointers*,
847868 contract_state_changes: DictAccess*,
848869 contract_class_changes: DictAccess*,
849870 outputs: OsCarriedOutputs*,
850- } (block_context: BlockContext*) {
871+ } (block_context: BlockContext*) -> (sender_address: felt ) {
851872 alloc_locals ;
852873
853874 local tx_version;
854875 %{ TxVersion %}
855876 if (tx_version == 0 ) {
856877 %{ SkipTx %}
857- return ();
878+ return (sender_address= 0 );
858879 }
859880
860881 // Guess transaction fields.
@@ -922,7 +943,7 @@ func execute_declare_transaction{
922943 key=[class_hash_ptr], prev_value=0 , new_value=compiled_class_hash
923944 );
924945 %{ SkipTx %}
925- return ();
946+ return (sender_address=sender_address );
926947 }
927948 }
928949
@@ -975,5 +996,5 @@ func execute_declare_transaction{
975996 );
976997 %{ EndTx %}
977998
978- return ();
999+ return (sender_address=sender_address );
9791000}
0 commit comments