@@ -892,6 +892,59 @@ def test_sufficient_balance_blob_tx_pre_fund_tx(
892
892
)
893
893
894
894
895
+ @pytest .mark .parametrize (
896
+ "tx_access_list" ,
897
+ [[], [AccessList (address = 100 , storage_keys = [100 , 200 ])]],
898
+ ids = ["no_access_list" , "access_list" ],
899
+ )
900
+ @pytest .mark .parametrize ("tx_max_fee_per_gas" , [7 , 14 ])
901
+ @pytest .mark .parametrize ("tx_max_priority_fee_per_gas" , [0 , 7 ])
902
+ @pytest .mark .parametrize ("tx_value" , [0 , 1 ])
903
+ @pytest .mark .parametrize (
904
+ "tx_calldata" ,
905
+ [b"" , b"\x00 " , b"\x01 " ],
906
+ ids = ["no_calldata" , "single_zero_calldata" ],
907
+ )
908
+ @pytest .mark .parametrize ("tx_max_fee_per_blob_gas" , [1 , 100 ])
909
+ @pytest .mark .parametrize (
910
+ "tx_gas" , [500_000 ], ids = ["" ]
911
+ ) # Increase gas to account for contract code
912
+ @pytest .mark .parametrize ("mid_tx_send_amount" , [0 , 100 ])
913
+ @pytest .mark .valid_from ("Cancun" )
914
+ def test_blob_gas_subtraction_tx (
915
+ state_test : StateTestFiller ,
916
+ state_env : Environment ,
917
+ pre : Dict ,
918
+ txs : List [Transaction ],
919
+ destination_account : str ,
920
+ mid_tx_send_amount : int ,
921
+ ):
922
+ """
923
+ Check that the blob gas fee for a transaction is subtracted from the sender balance before the
924
+ transaction is executed, including:
925
+
926
+ - Transactions with max fee equal or higher than current block base fee
927
+ - Transactions with and without priority fee
928
+ - Transactions with and without value
929
+ - Transactions with and without calldata
930
+ - Transactions with max fee per blob gas lower or higher than the priority fee
931
+ - Transactions where an externally owned account sends funds to the sender mid execution
932
+ """
933
+ assert len (txs ) == 1
934
+ pre [destination_account ] = Account (
935
+ balance = mid_tx_send_amount ,
936
+ code = Op .SSTORE (0 , Op .BALANCE (Op .ORIGIN ))
937
+ + Op .CALL (Op .GAS , Op .ORIGIN , mid_tx_send_amount , 0 , 0 , 0 , 0 )
938
+ + Op .SSTORE (1 , Op .BALANCE (Op .ORIGIN )),
939
+ )
940
+ state_test (
941
+ pre = pre ,
942
+ post = {},
943
+ tx = txs [0 ],
944
+ env = state_env ,
945
+ )
946
+
947
+
895
948
@pytest .mark .parametrize (
896
949
"blobs_per_tx" ,
897
950
all_valid_blob_combinations (),
0 commit comments