@@ -197,6 +197,7 @@ func execute_transactions_inner{
197
197
contract_class_changes: DictAccess*,
198
198
outputs: OsCarriedOutputs*,
199
199
} (block_context: BlockContext*, n_txs) {
200
+ %{ print (f " execute_transactions_inner: { ids.n_txs} transactions remaining. " ) %}
200
201
if (n_txs == 0 ) {
201
202
return ();
202
203
}
@@ -641,7 +642,7 @@ func check_and_increment_nonce{contract_state_changes: DictAccess*}(tx_info: TxI
641
642
%}
642
643
643
644
tempvar current_nonce = state_entry.nonce;
644
- with_attr error_message ("Unexpected nonce. Expected {current_nonce}, got {tx_info.nonce}. " ) {
645
+ with_attr error_message ("Unexpected nonce." ) {
645
646
assert current_nonce = tx_info.nonce;
646
647
}
647
648
@@ -701,6 +702,15 @@ func run_validate{
701
702
block_context=block_context, execution_context=validate_execution_context
702
703
);
703
704
if (is_deprecated == 0 ) {
705
+ %{
706
+ # Fetch the result, up to 100 elements.
707
+ result = memory.get_range(ids.retdata, min (100 , ids.retdata_size))
708
+
709
+ if result != [ids.VALIDATED ]:
710
+ print (" Invalid return value from __validate__:" )
711
+ print (f " Size: { ids.retdata_size} " )
712
+ print (f " Result (at most 100 elements): { result} " )
713
+ %}
704
714
assert retdata_size = 1 ;
705
715
assert retdata[0 ] = VALIDATED;
706
716
}
@@ -805,8 +815,10 @@ func execute_deploy_account_transaction{
805
815
local constructor_execution_context: ExecutionContext*, local salt
806
816
) = prepare_constructor_execution_context(block_info=block_context.block_info_for_validate);
807
817
local constructor_execution_info: ExecutionInfo* = constructor_execution_context.execution_info;
818
+ local sender_address = constructor_execution_info.contract_address;
808
819
809
820
// Prepare validate_deploy calldata.
821
+ local validate_deploy_calldata_size = constructor_execution_context.calldata_size + 2 ;
810
822
let (validate_deploy_calldata: felt *) = alloc();
811
823
assert validate_deploy_calldata[0 ] = constructor_execution_context.class_hash;
812
824
assert validate_deploy_calldata[1 ] = salt;
@@ -816,24 +828,6 @@ func execute_deploy_account_transaction{
816
828
len=constructor_execution_context.calldata_size,
817
829
);
818
830
819
- // Note that the members of execution_info.tx_info are not initialized at this point.
820
- local tx_info: TxInfo* = constructor_execution_info.tx_info;
821
- local deprecated_tx_info: DeprecatedTxInfo* = constructor_execution_context.deprecated_tx_info;
822
- local validate_deploy_execution_context: ExecutionContext* = new ExecutionContext(
823
- entry_point_type=ENTRY_POINT_TYPE_EXTERNAL,
824
- class_hash=constructor_execution_context.class_hash,
825
- calldata_size=constructor_execution_context.calldata_size + 2 ,
826
- calldata=validate_deploy_calldata,
827
- execution_info=new ExecutionInfo(
828
- block_info=block_context.block_info_for_validate,
829
- tx_info=tx_info,
830
- caller_address=constructor_execution_info.caller_address,
831
- contract_address=constructor_execution_info.contract_address,
832
- selector=VALIDATE_DEPLOY_ENTRY_POINT_SELECTOR,
833
- ),
834
- deprecated_tx_info=deprecated_tx_info,
835
- );
836
-
837
831
// Guess tx fields.
838
832
// Compute transaction hash and prepare transaction info.
839
833
// The version validation is done in `compute_deploy_account_transaction_hash()`.
@@ -853,7 +847,7 @@ func execute_deploy_account_transaction{
853
847
local common_tx_fields: CommonTxFields = CommonTxFields(
854
848
tx_hash_prefix=DEPLOY_ACCOUNT_HASH_PREFIX,
855
849
version=nondet %{ tx.version %} ,
856
- sender_address=constructor_execution_info.contract_address ,
850
+ sender_address=sender_address ,
857
851
max_fee=nondet %{ tx.max_fee if tx.version < 3 else 0 %} ,
858
852
chain_id=block_context.starknet_os_config.chain_id,
859
853
nonce=nondet %{ tx.nonce %} ,
@@ -875,7 +869,9 @@ func execute_deploy_account_transaction{
875
869
let poseidon_ptr = builtin_ptrs.selectable.poseidon;
876
870
with pedersen_ptr, poseidon_ptr {
877
871
let transaction_hash = compute_deploy_account_transaction_hash(
878
- common_fields=&common_tx_fields, execution_context=validate_deploy_execution_context
872
+ common_fields=&common_tx_fields,
873
+ calldata_size=validate_deploy_calldata_size,
874
+ calldata=validate_deploy_calldata,
879
875
);
880
876
}
881
877
update_builtin_ptrs(pedersen_ptr=pedersen_ptr, poseidon_ptr=poseidon_ptr);
@@ -886,9 +882,10 @@ func execute_deploy_account_transaction{
886
882
f " Computed hash = { ids.transaction_hash} , Expected hash = { tx.hash_value} . " )
887
883
%}
888
884
889
- // Assign the transaction info to both calls.
890
- // Note that both constructor_execution_context and
891
- // validate_deploy_execution_context hold this pointer.
885
+ // Initialize and fill the transaction info structs.
886
+ local tx_info: TxInfo* = constructor_execution_info.tx_info;
887
+ local deprecated_tx_info: DeprecatedTxInfo* = constructor_execution_context.deprecated_tx_info;
888
+
892
889
local signature_start: felt *;
893
890
local signature_len: felt ;
894
891
%{
@@ -898,7 +895,7 @@ func execute_deploy_account_transaction{
898
895
assert_nn_le(signature_len, SIERRA_ARRAY_LEN_BOUND - 1 );
899
896
assert [tx_info] = TxInfo(
900
897
version=common_tx_fields.version,
901
- account_contract_address=constructor_execution_info.contract_address ,
898
+ account_contract_address=sender_address ,
902
899
max_fee=common_tx_fields.max_fee,
903
900
signature_start=signature_start,
904
901
signature_end=&signature_start[signature_len],
@@ -923,23 +920,38 @@ func execute_deploy_account_transaction{
923
920
deploy_contract(
924
921
block_context=block_context, constructor_execution_context=constructor_execution_context
925
922
);
926
- let updated_execution_context = update_class_hash_in_execution_context(
927
- execution_context=validate_deploy_execution_context
928
- );
929
923
930
924
// Handle nonce here since 'deploy_contract' verifies that the nonce is zeroed.
931
925
check_and_increment_nonce(tx_info=tx_info);
932
926
933
- // Runs the account contract's "__validate_deploy__" entry point,
934
- // which is responsible for signature verification.
927
+ // Run the account contract's "__validate_deploy__" entry point.
928
+
929
+ // Fetch the newest state entry, after constructor invocation.
930
+ let (state_entry: StateEntry*) = dict_read{dict_ptr=contract_state_changes}(key=sender_address);
931
+ // Prepare execution context.
932
+ local validate_deploy_execution_context: ExecutionContext* = new ExecutionContext(
933
+ entry_point_type=ENTRY_POINT_TYPE_EXTERNAL,
934
+ class_hash=state_entry.class_hash,
935
+ calldata_size=validate_deploy_calldata_size,
936
+ calldata=validate_deploy_calldata,
937
+ execution_info=new ExecutionInfo(
938
+ block_info=block_context.block_info_for_validate,
939
+ tx_info=tx_info,
940
+ caller_address=constructor_execution_info.caller_address,
941
+ contract_address=sender_address,
942
+ selector=VALIDATE_DEPLOY_ENTRY_POINT_SELECTOR,
943
+ ),
944
+ deprecated_tx_info=deprecated_tx_info,
945
+ );
946
+ // Run the entrypoint.
935
947
let (retdata_size, retdata, is_deprecated) = select_execute_entry_point_func(
936
- block_context=block_context, execution_context=updated_execution_context
948
+ block_context=block_context, execution_context=validate_deploy_execution_context
937
949
);
938
950
if (is_deprecated == 0 ) {
939
951
assert retdata_size = 1 ;
940
952
assert retdata[0 ] = VALIDATED;
941
953
}
942
- charge_fee(block_context=block_context, tx_execution_context=updated_execution_context );
954
+ charge_fee(block_context=block_context, tx_execution_context=validate_deploy_execution_context );
943
955
944
956
%{ execution_helper.end_tx() %}
945
957
return ();
0 commit comments