@@ -3187,3 +3187,85 @@ def test_deploying_delegation_designation_contract(
31873187 tx .created_contract : Account .NONEXISTENT ,
31883188 },
31893189 )
3190+
3191+
3192+ @pytest .mark .parametrize (
3193+ "signer_balance" ,
3194+ [
3195+ pytest .param (0 , id = "empty_balance" ),
3196+ pytest .param (
3197+ 1 ,
3198+ id = "non_empty_balance" ,
3199+ marks = pytest .mark .execute (pytest .mark .skip (reason = "excessive pre-fund txs" )),
3200+ ),
3201+ ],
3202+ )
3203+ @pytest .mark .parametrize (
3204+ "max_gas" ,
3205+ [
3206+ pytest .param (
3207+ 120_000_000 ,
3208+ id = "120m" ,
3209+ marks = pytest .mark .execute (pytest .mark .skip (reason = "excessive gas" )),
3210+ ),
3211+ pytest .param (
3212+ 20_000_000 ,
3213+ id = "20m" ,
3214+ marks = pytest .mark .fill (pytest .mark .skip (reason = "execute-only test" )),
3215+ ),
3216+ ],
3217+ )
3218+ def test_many_delegations (
3219+ state_test : StateTestFiller ,
3220+ pre : Alloc ,
3221+ max_gas : int ,
3222+ signer_balance : int ,
3223+ ):
3224+ """
3225+ Perform as many delegations as possible in a single 120 million gas transaction.
3226+
3227+ Every delegation comes from a different signer.
3228+
3229+ The account of can be empty or not depending on the `signer_balance` parameter.
3230+
3231+ The transaction is expected to succeed and the state after the transaction is expected to have
3232+ the code of the entry contract set to 1.
3233+ """
3234+ gas_for_delegations = max_gas - 21_000 - 20_000 - (3 * 2 )
3235+
3236+ delegation_count = gas_for_delegations // Spec .PER_EMPTY_ACCOUNT_COST
3237+
3238+ success_slot = 1
3239+ entry_code = Op .SSTORE (success_slot , 1 ) + Op .STOP
3240+ entry_address = pre .deploy_contract (entry_code )
3241+
3242+ signers = [pre .fund_eoa (signer_balance ) for _ in range (delegation_count )]
3243+
3244+ tx = Transaction (
3245+ gas_limit = max_gas ,
3246+ to = entry_address ,
3247+ value = 0 ,
3248+ authorization_list = [
3249+ AuthorizationTuple (
3250+ address = Address (i + 1 ),
3251+ nonce = 0 ,
3252+ signer = signer ,
3253+ )
3254+ for (i , signer ) in enumerate (signers )
3255+ ],
3256+ sender = pre .fund_eoa (),
3257+ )
3258+
3259+ post = {entry_address : Account (storage = {success_slot : 1 },),} | {
3260+ signer : Account (
3261+ code = Spec .delegation_designation (Address (i + 1 )),
3262+ )
3263+ for (i , signer ) in enumerate (signers )
3264+ }
3265+
3266+ state_test (
3267+ env = Environment (),
3268+ pre = pre ,
3269+ tx = tx ,
3270+ post = post ,
3271+ )
0 commit comments