@@ -3,10 +3,11 @@ use blockifier_test_utils::calldata::create_calldata;
3
3
use blockifier_test_utils:: contracts:: FeatureContract ;
4
4
use rstest:: fixture;
5
5
use starknet_api:: abi:: abi_utils:: get_fee_token_var_address;
6
- use starknet_api:: block:: { FeeType , GasPrice } ;
6
+ use starknet_api:: block:: { BlockNumber , BlockTimestamp , FeeType , GasPrice } ;
7
7
use starknet_api:: contract_class:: compiled_class_hash:: HashVersion ;
8
8
use starknet_api:: contract_class:: { ClassInfo , ContractClass , SierraVersion } ;
9
- use starknet_api:: core:: { ClassHash , ContractAddress , Nonce } ;
9
+ use starknet_api:: core:: { ChainId , ClassHash , ContractAddress , EntryPointSelector , Nonce } ;
10
+ use starknet_api:: data_availability:: DataAvailabilityMode ;
10
11
use starknet_api:: executable_transaction:: TransactionType ;
11
12
use starknet_api:: execution_resources:: { GasAmount , GasVector } ;
12
13
use starknet_api:: test_utils:: declare:: executable_declare_tx;
@@ -26,15 +27,23 @@ use starknet_api::test_utils::{
26
27
MAX_FEE ,
27
28
} ;
28
29
use starknet_api:: transaction:: fields:: {
30
+ AccountDeploymentData ,
29
31
AllResourceBounds ,
30
32
ContractAddressSalt ,
31
33
Fee ,
32
34
GasVectorComputationMode ,
35
+ PaymasterData ,
36
+ Resource ,
33
37
ResourceBounds ,
34
38
TransactionSignature ,
35
39
ValidResourceBounds ,
36
40
} ;
37
- use starknet_api:: transaction:: { constants, TransactionVersion } ;
41
+ use starknet_api:: transaction:: {
42
+ constants,
43
+ TransactionHash ,
44
+ TransactionVersion ,
45
+ QUERY_VERSION_BASE ,
46
+ } ;
38
47
use starknet_api:: { calldata, declare_tx_args, deploy_account_tx_args, felt, invoke_tx_args} ;
39
48
use starknet_types_core:: felt:: Felt ;
40
49
use strum:: IntoEnumIterator ;
@@ -452,3 +461,125 @@ pub fn emit_n_events_tx(
452
461
453
462
AccountTransaction :: new_for_sequencing ( tx)
454
463
}
464
+
465
+ /// Utility struct to test the execution info syscall.
466
+ /// For simplicity, some fields are not included in the struct, and assumed empty.
467
+ pub struct ExpectedExecutionInfo {
468
+ pub version : TransactionVersion ,
469
+ pub account_address : ContractAddress ,
470
+ pub max_fee : Fee ,
471
+ pub transaction_hash : TransactionHash ,
472
+ pub chain_id : ChainId ,
473
+ pub nonce : Nonce ,
474
+ pub resource_bounds : ValidResourceBounds ,
475
+ pub paymaster_data : PaymasterData ,
476
+ pub nonce_data_availability_mode : DataAvailabilityMode ,
477
+ pub fee_data_availability_mode : DataAvailabilityMode ,
478
+ pub account_deployment_data : AccountDeploymentData ,
479
+ pub caller_address : ContractAddress ,
480
+ pub contract_address : ContractAddress ,
481
+ pub entry_point_selector : EntryPointSelector ,
482
+ pub block_number : BlockNumber ,
483
+ pub block_timestamp : BlockTimestamp ,
484
+ pub sequencer_address : ContractAddress ,
485
+ }
486
+
487
+ impl ExpectedExecutionInfo {
488
+ pub fn new (
489
+ only_query : bool ,
490
+ account_address : ContractAddress ,
491
+ caller_address : ContractAddress ,
492
+ contract_address : ContractAddress ,
493
+ chain_id : ChainId ,
494
+ entry_point_selector : EntryPointSelector ,
495
+ block_number : BlockNumber ,
496
+ block_timestamp : BlockTimestamp ,
497
+ sequencer_address : ContractAddress ,
498
+ resource_bounds : ValidResourceBounds ,
499
+ nonce : Nonce ,
500
+ ) -> Self {
501
+ let mut version = Felt :: THREE ;
502
+ if only_query {
503
+ version += * QUERY_VERSION_BASE ;
504
+ }
505
+ Self {
506
+ version : TransactionVersion ( version) ,
507
+ account_address,
508
+ caller_address,
509
+ contract_address,
510
+ chain_id,
511
+ entry_point_selector,
512
+ block_number,
513
+ block_timestamp,
514
+ sequencer_address,
515
+ resource_bounds,
516
+ nonce,
517
+ max_fee : Fee :: default ( ) ,
518
+ transaction_hash : TransactionHash :: default ( ) ,
519
+ paymaster_data : PaymasterData :: default ( ) ,
520
+ nonce_data_availability_mode : DataAvailabilityMode :: default ( ) ,
521
+ fee_data_availability_mode : DataAvailabilityMode :: default ( ) ,
522
+ account_deployment_data : AccountDeploymentData :: default ( ) ,
523
+ }
524
+ }
525
+
526
+ pub fn to_syscall_result ( self ) -> Vec < Felt > {
527
+ let expected_tx_info = vec ! [
528
+ self . version. 0 ,
529
+ * * self . account_address,
530
+ self . max_fee. 0 . into( ) ,
531
+ Felt :: ZERO ,
532
+ self . transaction_hash. 0 ,
533
+ Felt :: from_hex_unchecked( & self . chain_id. as_hex( ) ) ,
534
+ self . nonce. 0 ,
535
+ ] ;
536
+
537
+ let expected_resource_bounds = match self . resource_bounds {
538
+ ValidResourceBounds :: L1Gas ( l1_gas) => vec ! [
539
+ Felt :: ONE ,
540
+ felt!( Resource :: L1Gas . to_hex( ) ) ,
541
+ felt!( l1_gas. max_amount. 0 ) ,
542
+ felt!( l1_gas. max_price_per_unit. 0 ) ,
543
+ ] ,
544
+ ValidResourceBounds :: AllResources ( AllResourceBounds {
545
+ l1_gas,
546
+ l2_gas,
547
+ l1_data_gas,
548
+ } ) => {
549
+ vec ! [
550
+ Felt :: THREE ,
551
+ felt!( Resource :: L1Gas . to_hex( ) ) ,
552
+ felt!( l1_gas. max_amount. 0 ) ,
553
+ felt!( l1_gas. max_price_per_unit. 0 ) ,
554
+ felt!( Resource :: L2Gas . to_hex( ) ) ,
555
+ felt!( l2_gas. max_amount. 0 ) ,
556
+ felt!( l2_gas. max_price_per_unit. 0 ) ,
557
+ felt!( Resource :: L1DataGas . to_hex( ) ) ,
558
+ felt!( l1_data_gas. max_amount. 0 ) ,
559
+ felt!( l1_data_gas. max_price_per_unit. 0 ) ,
560
+ ]
561
+ }
562
+ } ;
563
+
564
+ // Tip, Paymaster data, Nonce DA, Fee DA, Account data.
565
+ let expected_unsupported_fields = vec ! [ Felt :: ZERO ; 5 ] ;
566
+
567
+ let expected_call_info =
568
+ vec ! [ * * self . caller_address, * * self . contract_address, self . entry_point_selector. 0 ] ;
569
+ let expected_block_info = vec ! [
570
+ felt!( self . block_number. 0 ) ,
571
+ felt!( self . block_timestamp. 0 ) ,
572
+ * * self . sequencer_address,
573
+ ] ;
574
+
575
+ [
576
+ expected_block_info,
577
+ expected_tx_info,
578
+ expected_resource_bounds,
579
+ expected_unsupported_fields,
580
+ expected_call_info,
581
+ ]
582
+ . concat ( )
583
+ . into ( )
584
+ }
585
+ }
0 commit comments