@@ -729,41 +729,33 @@ mod transaction_tests {
729
729
DEFAULT_VALIDATE_MAX_N_STEPS ,
730
730
} ,
731
731
} ,
732
+ execution:: TransactionExecutionInfo ,
732
733
felt:: felt_str,
733
734
state:: cached_state:: CachedState ,
734
735
} ;
735
736
use std:: sync:: Arc ;
736
737
737
- /// - Transaction Hash: `0x014640564509873cf9d24a311e1207040c8b60efd38d96caef79855f0b0075d5`
738
- /// - Network: `mainnet`
739
- /// - Type: `Invoke`
740
- /// - Contract: StarkGate `0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7`
741
- /// - Entrypoint: `transfer(recipient, amount)`
742
- /// - Fee discrepancy: test=83714806176032, explorer=67749104314311, diff=15965701861721 (23%)
743
- /// - Link to Explorer: https://starkscan.co/tx/0x014640564509873cf9d24a311e1207040c8b60efd38d96caef79855f0b0075d5
744
- #[ test]
745
- fn test_invoke_0x014640564509873cf9d24a311e1207040c8b60efd38d96caef79855f0b0075d5 ( ) {
746
- let tx_hash = "014640564509873cf9d24a311e1207040c8b60efd38d96caef79855f0b0075d5" ;
738
+ fn test_tx (
739
+ tx_hash : & str ,
740
+ network : RpcChain ,
741
+ block_number : u64 ,
742
+ gas_price : u128 ,
743
+ ) -> TransactionExecutionInfo {
744
+ let tx_hash = tx_hash. strip_prefix ( "0x" ) . unwrap ( ) ;
747
745
748
746
// Instantiate the RPC StateReader and the CachedState
749
- let rpc_state = Arc :: new ( RpcState :: new (
750
- RpcChain :: MainNet ,
751
- BlockValue :: Number ( serde_json:: to_value ( 90_006 ) . unwrap ( ) ) ,
752
- ) ) ;
747
+ let block = BlockValue :: Number ( serde_json:: to_value ( block_number) . unwrap ( ) ) ;
748
+ let rpc_state = Arc :: new ( RpcState :: new ( network, block) ) ;
753
749
let mut state = CachedState :: new ( rpc_state. clone ( ) , None , None ) ;
754
750
755
- // BlockContext with mainnet data.
756
- // TODO look how to get this value from RPC call.
757
- let gas_price_str = "13563643256" ;
758
- let gas_price_u128 = gas_price_str. parse :: < u128 > ( ) . unwrap ( ) ;
759
-
760
751
let fee_token_address = Address ( felt_str ! (
761
752
"049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7" ,
762
753
16
763
754
) ) ;
755
+
764
756
let network: StarknetChainId = rpc_state. chain . into ( ) ;
765
757
let starknet_os_config =
766
- StarknetOsConfig :: new ( network. to_felt ( ) , fee_token_address, gas_price_u128 ) ;
758
+ StarknetOsConfig :: new ( network. to_felt ( ) , fee_token_address, gas_price ) ;
767
759
768
760
let block_info = rpc_state. get_block_info ( starknet_os_config. clone ( ) ) ;
769
761
@@ -780,7 +772,26 @@ mod transaction_tests {
780
772
) ;
781
773
782
774
let tx = rpc_state. get_transaction ( tx_hash) ;
783
- let result = tx. execute ( & mut state, & block_context, 0 ) . unwrap ( ) ;
775
+
776
+ tx. execute ( & mut state, & block_context, 0 ) . unwrap ( )
777
+ }
778
+
779
+ /// - Transaction Hash: `0x014640564509873cf9d24a311e1207040c8b60efd38d96caef79855f0b0075d5`
780
+ /// - Network: `mainnet`
781
+ /// - Type: `Invoke`
782
+ /// - Contract: StarkGate `0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7`
783
+ /// - Entrypoint: `transfer(recipient, amount)`
784
+ /// - Fee discrepancy: test=83714806176032, explorer=67749104314311, diff=15965701861721 (23%)
785
+ /// - Link to Explorer: https://starkscan.co/tx/0x014640564509873cf9d24a311e1207040c8b60efd38d96caef79855f0b0075d5
786
+ #[ test]
787
+ fn test_invoke_0x014640564509873cf9d24a311e1207040c8b60efd38d96caef79855f0b0075d5 ( ) {
788
+ let result = test_tx (
789
+ "0x014640564509873cf9d24a311e1207040c8b60efd38d96caef79855f0b0075d5" ,
790
+ RpcChain :: MainNet ,
791
+ 90_006 ,
792
+ 13563643256 ,
793
+ ) ;
794
+
784
795
dbg ! ( & result. actual_resources) ;
785
796
dbg ! ( & result. actual_fee) ; // test=83714806176032, explorer=67749104314311, diff=15965701861721 (23%)
786
797
dbg ! ( & result. call_info. clone( ) . unwrap( ) . execution_resources) ; // Ok with explorer
@@ -796,45 +807,13 @@ mod transaction_tests {
796
807
/// - Link to Explorer: https://starkscan.co/tx/0x06da92cfbdceac5e5e94a1f40772d6c79d34f011815606742658559ec77b6955
797
808
#[ test]
798
809
fn test_invoke_mainnet_0x06da92cfbdceac5e5e94a1f40772d6c79d34f011815606742658559ec77b6955 ( ) {
799
- // Tx Hash without the "0x" prefix.
800
- let tx_hash = "06da92cfbdceac5e5e94a1f40772d6c79d34f011815606742658559ec77b6955" ;
801
-
802
- // Create RPC StateReader and CachedState
803
- let rpc_state = Arc :: new ( RpcState :: new (
810
+ let result = test_tx (
811
+ "0x06da92cfbdceac5e5e94a1f40772d6c79d34f011815606742658559ec77b6955" ,
804
812
RpcChain :: MainNet ,
805
- BlockValue :: Number ( serde_json:: to_value ( 90_002 ) . unwrap ( ) ) ,
806
- ) ) ;
807
- let mut state = CachedState :: new ( rpc_state. clone ( ) , None , None ) ;
808
-
809
- // BlockContext with mainnet data.
810
- // TODO look how to get this value from RPC call.
811
- let gas_price_str = "13572248835" ; // from block 90_002
812
- let gas_price_u128 = gas_price_str. parse :: < u128 > ( ) . unwrap ( ) ;
813
-
814
- let fee_token_address = Address ( felt_str ! (
815
- "049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7" ,
816
- 16
817
- ) ) ;
818
- let network: StarknetChainId = rpc_state. chain . into ( ) ;
819
- let starknet_os_config =
820
- StarknetOsConfig :: new ( network. to_felt ( ) , fee_token_address, gas_price_u128) ;
821
-
822
- let block_info = rpc_state. get_block_info ( starknet_os_config. clone ( ) ) ;
823
-
824
- let block_context = BlockContext :: new (
825
- starknet_os_config,
826
- DEFAULT_CONTRACT_STORAGE_COMMITMENT_TREE_HEIGHT ,
827
- DEFAULT_GLOBAL_STATE_COMMITMENT_TREE_HEIGHT ,
828
- DEFAULT_CAIRO_RESOURCE_FEE_WEIGHTS . clone ( ) ,
829
- DEFAULT_INVOKE_TX_MAX_N_STEPS ,
830
- DEFAULT_VALIDATE_MAX_N_STEPS ,
831
- block_info,
832
- Default :: default ( ) ,
833
- true ,
813
+ 90_002 ,
814
+ 13572248835 ,
834
815
) ;
835
816
836
- let tx = rpc_state. get_transaction ( tx_hash) ;
837
- let result = tx. execute ( & mut state, & block_context, 0 ) . unwrap ( ) ;
838
817
dbg ! ( & result. actual_resources) ;
839
818
dbg ! ( & result. actual_fee) ; // test=267319013054160, explorer=219298652474858, diff=48020360579302 (22%)
840
819
dbg ! ( & result. call_info. clone( ) . unwrap( ) . execution_resources) ; // Ok with explorer
@@ -849,47 +828,14 @@ mod transaction_tests {
849
828
/// - Fee discrepancy: test=7252831227950, explorer=7207614784695, diff=45216443255 (0.06%)
850
829
/// - Link to Explorer: https://testnet.starkscan.co/tx/0x074dab0828ec1b6cfde5188c41d41af1c198192a7d118217f95a802aa923dacf
851
830
#[ test]
852
- fn test_invoke_mainnet_0x074dab0828ec1b6cfde5188c41d41af1c198192a7d118217f95a802aa923dacf ( ) {
853
- // Tx Hash without the "0x" prefix.
854
- let tx_hash_str = "074dab0828ec1b6cfde5188c41d41af1c198192a7d118217f95a802aa923dacf" ;
855
-
856
- // Instantiate CachedState
857
- let rpc_state = Arc :: new ( RpcState :: new (
831
+ fn test_0x074dab0828ec1b6cfde5188c41d41af1c198192a7d118217f95a802aa923dacf ( ) {
832
+ let result = test_tx (
833
+ "0x074dab0828ec1b6cfde5188c41d41af1c198192a7d118217f95a802aa923dacf" ,
858
834
RpcChain :: TestNet ,
859
- BlockValue :: Number ( serde_json:: to_value ( 838683 ) . unwrap ( ) ) ,
860
- ) ) ;
861
-
862
- let mut state = CachedState :: new ( rpc_state. clone ( ) , None , None ) ;
863
-
864
- // BlockContext with mainnet data.
865
- // TODO look how to get this value from RPC call.
866
- let gas_price_str = "2917470325" ; // from block 838683
867
- let gas_price_u128 = gas_price_str. parse :: < u128 > ( ) . unwrap ( ) ;
868
-
869
- let fee_token_address = Address ( felt_str ! (
870
- "049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7" ,
871
- 16
872
- ) ) ;
873
- let network: StarknetChainId = rpc_state. chain . into ( ) ;
874
- let starknet_os_config =
875
- StarknetOsConfig :: new ( network. to_felt ( ) , fee_token_address, gas_price_u128) ;
876
-
877
- let block_info = rpc_state. get_block_info ( starknet_os_config. clone ( ) ) ;
878
-
879
- let block_context = BlockContext :: new (
880
- starknet_os_config,
881
- DEFAULT_CONTRACT_STORAGE_COMMITMENT_TREE_HEIGHT ,
882
- DEFAULT_GLOBAL_STATE_COMMITMENT_TREE_HEIGHT ,
883
- DEFAULT_CAIRO_RESOURCE_FEE_WEIGHTS . clone ( ) ,
884
- DEFAULT_INVOKE_TX_MAX_N_STEPS ,
885
- DEFAULT_VALIDATE_MAX_N_STEPS ,
886
- block_info,
887
- Default :: default ( ) ,
888
- true ,
835
+ 838683 ,
836
+ 2917470325 ,
889
837
) ;
890
- let tx = rpc_state. get_transaction ( tx_hash_str) ;
891
838
892
- let result = tx. execute ( & mut state, & block_context, 0 ) . unwrap ( ) ;
893
839
dbg ! ( & result. actual_resources) ;
894
840
dbg ! ( & result. actual_fee) ; // test=7252831227950, explorer=7207614784695, diff=45216443255 (0.06%)
895
841
dbg ! ( & result. call_info. clone( ) . unwrap( ) . execution_resources) ; // Ok with explorer
@@ -905,46 +851,70 @@ mod transaction_tests {
905
851
/// - Link to Explorer: https://testnet-2.starkscan.co/tx/0x019feb888a2d53ffddb7a1750264640afab8e9c23119e648b5259f1b5e7d51bc
906
852
#[ test]
907
853
fn test_invoke_testnet2_0x019feb888a2d53ffddb7a1750264640afab8e9c23119e648b5259f1b5e7d51bc ( ) {
908
- // Tx Hash without the "0x" prefix.
909
- let tx_hash_str = "019feb888a2d53ffddb7a1750264640afab8e9c23119e648b5259f1b5e7d51bc" ;
910
-
911
- // Instantiate the RPC StateReader and the CachedState
912
- let rpc_state = Arc :: new ( RpcState :: new (
854
+ let result = test_tx (
855
+ "0x019feb888a2d53ffddb7a1750264640afab8e9c23119e648b5259f1b5e7d51bc" ,
913
856
RpcChain :: TestNet2 ,
914
- BlockValue :: Number ( serde_json:: to_value ( 123001 ) . unwrap ( ) ) ,
915
- ) ) ;
857
+ 123001 ,
858
+ 272679647 ,
859
+ ) ;
916
860
917
- // BlockContext with mainnet data.
918
- // TODO look how to get this value from RPC call.
919
- let gas_price_str = "272679647" ; // from block 123001
920
- let gas_price_u128 = gas_price_str. parse :: < u128 > ( ) . unwrap ( ) ;
861
+ dbg ! ( & result. actual_resources) ;
862
+ dbg ! ( & result. actual_fee) ; // test=6361070805216, explorer=47292465953700, diff=5888146145679 (0.13%)
863
+ dbg ! ( & result. call_info. clone( ) . unwrap( ) . execution_resources) ; // Ok with explorer
864
+ dbg ! ( & result. call_info. unwrap( ) . internal_calls. len( ) ) ; // Ok with explorer
865
+ }
921
866
922
- let fee_token_address = Address ( felt_str ! (
923
- "49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7" ,
924
- 16
925
- ) ) ;
867
+ // tx_hash = 0x02e31c976f649ba05da82e4c6a054a9a41961adda4c3dea26e6b523f4f18b382
868
+ // testnet
869
+ // freeMint entrypoint
870
+ // 6164000061640
871
+ // 6191000061910
872
+ // 0.004% difference
873
+ // Link to explorer: https://testnet.starkscan.co/tx/0x02e31c976f649ba05da82e4c6a054a9a41961adda4c3dea26e6b523f4f18b382
874
+ #[ test]
875
+ fn test_0x02e31c976f649ba05da82e4c6a054a9a41961adda4c3dea26e6b523f4f18b382 ( ) {
876
+ let result = test_tx (
877
+ "0x02e31c976f649ba05da82e4c6a054a9a41961adda4c3dea26e6b523f4f18b382" ,
878
+ RpcChain :: TestNet ,
879
+ 846582 ,
880
+ 1000000010 ,
881
+ ) ;
926
882
927
- let mut state = CachedState :: new ( rpc_state. clone ( ) , None , None ) ;
883
+ dbg ! ( & result. actual_resources) ;
884
+ dbg ! ( & result. actual_fee) ; // test=6361070805216, explorer=47292465953700, diff=5888146145679 (0.13%)
885
+ dbg ! ( & result. call_info. clone( ) . unwrap( ) . execution_resources) ; // Ok with explorer
886
+ dbg ! ( & result. call_info. unwrap( ) . internal_calls. len( ) ) ; // Ok with explorer
887
+ }
928
888
929
- let network: StarknetChainId = rpc_state. chain . into ( ) ;
930
- let starknet_os_config =
931
- StarknetOsConfig :: new ( network. to_felt ( ) , fee_token_address, gas_price_u128) ;
889
+ /// tx: 0x26a1a5b5f2b3390302ade67c766cc94804fd41c86c5ee37e20c6415dc39358c
890
+ /// Network: mainnet
891
+ /// Fee: test=263050867669716, explorer=306031925226186, diff=16%
892
+ /// Entrypoint evolve(game_id)
893
+ /// Link to explorer: https://starkscan.co/tx/0x026a1a5b5f2b3390302ade67c766cc94804fd41c86c5ee37e20c6415dc39358c
894
+ #[ test]
895
+ fn test_0x26a1a5b5f2b3390302ade67c766cc94804fd41c86c5ee37e20c6415dc39358c ( ) {
896
+ let result = test_tx (
897
+ "0x26a1a5b5f2b3390302ade67c766cc94804fd41c86c5ee37e20c6415dc39358c" ,
898
+ RpcChain :: MainNet ,
899
+ 155054 ,
900
+ 33977120598 ,
901
+ ) ;
932
902
933
- let block_info = rpc_state. get_block_info ( starknet_os_config. clone ( ) ) ;
903
+ dbg ! ( & result. actual_resources) ;
904
+ dbg ! ( & result. actual_fee) ; // test=6361070805216, explorer=47292465953700, diff=5888146145679 (0.13%)
905
+ dbg ! ( & result. call_info. clone( ) . unwrap( ) . execution_resources) ; // Ok with explorer
906
+ dbg ! ( & result. call_info. unwrap( ) . internal_calls. len( ) ) ; // Ok with explorer
907
+ }
934
908
935
- let block_context = BlockContext :: new (
936
- starknet_os_config,
937
- DEFAULT_CONTRACT_STORAGE_COMMITMENT_TREE_HEIGHT ,
938
- DEFAULT_GLOBAL_STATE_COMMITMENT_TREE_HEIGHT ,
939
- DEFAULT_CAIRO_RESOURCE_FEE_WEIGHTS . clone ( ) ,
940
- DEFAULT_INVOKE_TX_MAX_N_STEPS ,
941
- DEFAULT_VALIDATE_MAX_N_STEPS ,
942
- block_info,
943
- Default :: default ( ) ,
944
- true ,
909
+ #[ test]
910
+ fn test_0x00eef6ba6741da8769192fac9d28c6631cf66f9e7c4e880b886ef6a2e550e4e2 ( ) {
911
+ let result = test_tx (
912
+ "0x00eef6ba6741da8769192fac9d28c6631cf66f9e7c4e880b886ef6a2e550e4e2" ,
913
+ RpcChain :: MainNet ,
914
+ 156105 ,
915
+ 18348936116 ,
945
916
) ;
946
- let tx = rpc_state. get_transaction ( tx_hash_str) ;
947
- let result = tx. execute ( & mut state, & block_context, 0 ) . unwrap ( ) ;
917
+
948
918
dbg ! ( & result. actual_resources) ;
949
919
dbg ! ( & result. actual_fee) ; // test=6361070805216, explorer=47292465953700, diff=5888146145679 (0.13%)
950
920
dbg ! ( & result. call_info. clone( ) . unwrap( ) . execution_resources) ; // Ok with explorer
0 commit comments