@@ -485,7 +485,7 @@ async fn test_execute_txs_inner_resources() {
485485 let version = StarknetVersion :: LATEST ;
486486 let mut raw_vc: RawVersionedConstants =
487487 serde_json:: from_str ( VersionedConstants :: json_str ( & version) . unwrap ( ) ) . unwrap ( ) ;
488- const N_TXS : usize = 5 ;
488+ const N_TXS : usize = 6 ;
489489
490490 let OsResourcesTestSetup {
491491 stable_contract_address,
@@ -494,10 +494,10 @@ async fn test_execute_txs_inner_resources() {
494494 ..
495495 } = setup_test_builder ( ) . await ;
496496
497- // Prepare the deploy account tx in advance, so we can fund the address before moving to the
497+ // Prepare the deploy account txs in advance, so we can fund the address before moving to the
498498 // next block (just so the funding tx is not in our measurement block). Use the stable contract
499499 // to prevent noise from changing contract address.
500- let deploy_tx = DeployAccountTransaction :: create (
500+ let deploy_tx_base = DeployAccountTransaction :: create (
501501 deploy_account_tx (
502502 deploy_account_tx_args ! {
503503 class_hash: stable_contract_class_hash,
@@ -512,7 +512,23 @@ async fn test_execute_txs_inner_resources() {
512512 & test_builder. chain_id ( ) ,
513513 )
514514 . unwrap ( ) ;
515- test_builder. add_fund_address_tx_with_default_amount ( deploy_tx. contract_address ) ;
515+ test_builder. add_fund_address_tx_with_default_amount ( deploy_tx_base. contract_address ) ;
516+ let deploy_tx_extra = DeployAccountTransaction :: create (
517+ deploy_account_tx (
518+ deploy_account_tx_args ! {
519+ class_hash: stable_contract_class_hash,
520+ resource_bounds: * NON_TRIVIAL_RESOURCE_BOUNDS ,
521+ constructor_calldata: calldata![ Felt :: ONE , Felt :: ZERO ] ,
522+ // The stable contract was already deployed (from deployer address zero) with
523+ // trivial salt, so use non-trivial salt to get a new address.
524+ contract_address_salt: ContractAddressSalt ( Felt :: from( 100 ) ) ,
525+ } ,
526+ Nonce :: default ( ) ,
527+ ) ,
528+ & test_builder. chain_id ( ) ,
529+ )
530+ . unwrap ( ) ;
531+ test_builder. add_fund_address_tx_with_default_amount ( deploy_tx_extra. contract_address ) ;
516532 test_builder. move_to_next_block ( ) ;
517533
518534 // Invoke.
@@ -555,7 +571,8 @@ async fn test_execute_txs_inner_resources() {
555571 ) ;
556572
557573 // Deploy account (pre-prepared).
558- test_builder. add_deploy_account_tx ( deploy_tx) ;
574+ test_builder. add_deploy_account_tx ( deploy_tx_base) ;
575+ test_builder. add_deploy_account_tx ( deploy_tx_extra) ;
559576
560577 // L1 handler.
561578 test_builder. add_l1_handler (
@@ -598,22 +615,28 @@ async fn test_execute_txs_inner_resources() {
598615 test_output. perform_default_validations ( ) ;
599616
600617 // Fetch the OS resources for each tx.
601- let [ invoke_base, invoke_extra, declare_overhead, deploy_account_overhead, l1_handler_overhead] : [ ExecutionResources ; N_TXS ] =
602- test_output
603- . runner_output
604- . txs_trace
605- . iter ( )
606- . rev ( )
607- . take ( N_TXS )
608- . rev ( )
609- . map ( |trace| trace. get_resources ( ) . unwrap ( ) . clone ( ) )
610- . zip ( business_logic_resources)
611- . map ( |( os_resources, business_logic_resources) | {
612- ( & os_resources - & business_logic_resources) . filter_unused_builtins ( )
613- } )
614- . collect :: < Vec < _ > > ( )
615- . try_into ( )
616- . unwrap ( ) ;
618+ let [
619+ invoke_base,
620+ invoke_extra,
621+ declare_overhead,
622+ deploy_account_base,
623+ deploy_account_extra,
624+ l1_handler_overhead,
625+ ] : [ ExecutionResources ; N_TXS ] = test_output
626+ . runner_output
627+ . txs_trace
628+ . iter ( )
629+ . rev ( )
630+ . take ( N_TXS )
631+ . rev ( )
632+ . map ( |trace| trace. get_resources ( ) . unwrap ( ) . clone ( ) )
633+ . zip ( business_logic_resources)
634+ . map ( |( os_resources, business_logic_resources) | {
635+ ( & os_resources - & business_logic_resources) . filter_unused_builtins ( )
636+ } )
637+ . collect :: < Vec < _ > > ( )
638+ . try_into ( )
639+ . unwrap ( ) ;
617640
618641 // Invoke: variable cost, with scaling of 2.
619642 let VariableResourceParams :: WithFactor ( mut invoke_resources_params) = raw_vc
@@ -662,7 +685,6 @@ async fn test_execute_txs_inner_resources() {
662685 . insert ( TransactionType :: Declare , VariableResourceParams :: Constant ( declare_overhead) ) ;
663686
664687 // Deploy account: variable cost, with scaling of 2.
665- // TODO(Dori): Compute linear factor cost.
666688 let VariableResourceParams :: WithFactor ( mut deploy_account_resources_params) =
667689 raw_vc. os_resources . execute_txs_inner . get ( & TransactionType :: DeployAccount ) . unwrap ( ) . clone ( )
668690 else {
@@ -671,7 +693,7 @@ async fn test_execute_txs_inner_resources() {
671693 raw_vc. os_resources. execute_txs_inner. get( & TransactionType :: DeployAccount ) . unwrap( )
672694 ) ;
673695 } ;
674- let VariableCallDataFactor :: Scaled ( ref deploy_account_scaling_factor) =
696+ let VariableCallDataFactor :: Scaled ( mut deploy_account_scaling_factor) =
675697 deploy_account_resources_params. calldata_factor
676698 else {
677699 panic ! (
@@ -684,7 +706,11 @@ async fn test_execute_txs_inner_resources() {
684706 "Deploy account scaling factor has unexpected value: {:?}" ,
685707 deploy_account_scaling_factor. scaling_factor
686708 ) ;
687- deploy_account_resources_params. constant = deploy_account_overhead;
709+ deploy_account_scaling_factor. resources =
710+ ( & deploy_account_extra - & deploy_account_base) . filter_unused_builtins ( ) ;
711+ deploy_account_resources_params. calldata_factor =
712+ VariableCallDataFactor :: Scaled ( deploy_account_scaling_factor) ;
713+ deploy_account_resources_params. constant = deploy_account_base;
688714 raw_vc. os_resources . execute_txs_inner . insert (
689715 TransactionType :: DeployAccount ,
690716 VariableResourceParams :: WithFactor ( deploy_account_resources_params) ,
0 commit comments