@@ -260,9 +260,9 @@ def run_test_full_random_operations(spec, state, rng=Random(2080)):
260
260
261
261
262
262
def get_random_execution_requests (spec , state , rng ):
263
- deposits = get_random_deposits_requests (spec , state , rng )
264
- withdrawals = get_random_withdrawals_requests (spec , state , rng )
265
- consolidations = get_random_consolidations_requests (spec , state , rng )
263
+ deposits = get_random_deposit_requests (spec , state , rng )
264
+ withdrawals = get_random_withdrawal_requests (spec , state , rng )
265
+ consolidations = get_random_consolidation_requests (spec , state , rng )
266
266
267
267
execution_requests = spec .ExecutionRequests (
268
268
deposits = deposits ,
@@ -273,19 +273,17 @@ def get_random_execution_requests(spec, state, rng):
273
273
return execution_requests
274
274
275
275
276
- def get_random_deposits_requests (spec , state , rng , num_deposits = None ):
276
+ def get_random_deposit_requests (spec , state , rng , num_deposits = None ):
277
277
if num_deposits is None :
278
278
num_deposits = rng .randint (0 , spec .MAX_DEPOSIT_REQUESTS_PER_PAYLOAD )
279
279
280
280
deposit_data_leaves = [spec .DepositData () for _ in range (len (state .validators ))]
281
281
282
- deposits_requests = []
283
-
284
- for i in range (num_deposits ):
282
+ deposit_requests = []
283
+ for _ in range (num_deposits ):
285
284
index = rng .randrange (0 , num_deposits )
286
285
withdrawal_pubkey = pubkeys [index ]
287
286
withdrawal_credentials = spec .BLS_WITHDRAWAL_PREFIX + spec .hash (withdrawal_pubkey )[1 :]
288
-
289
287
deposit , _ , _ = build_deposit (
290
288
spec ,
291
289
deposit_data_leaves ,
@@ -295,78 +293,60 @@ def get_random_deposits_requests(spec, state, rng, num_deposits=None):
295
293
withdrawal_credentials = withdrawal_credentials ,
296
294
signed = True ,
297
295
)
298
-
299
- deposit_request = spec .DepositRequest (
296
+ deposit_requests .append (spec .DepositRequest (
300
297
pubkey = deposit .data .pubkey ,
301
298
withdrawal_credentials = deposit .data .withdrawal_credentials ,
302
299
amount = deposit .data .amount ,
303
300
signature = deposit .data .signature ,
304
- index = deposit .data .index ,
305
- )
306
-
307
- deposits_requests .append (deposit_request )
301
+ index = rng .randrange (0 , 2 ** 64 ),
302
+ ))
308
303
309
- return deposits_requests
304
+ return deposit_requests
310
305
311
306
312
- def get_random_withdrawals_requests (spec , state , rng , num_withdrawals = None ):
307
+ def get_random_withdrawal_requests (spec , state , rng , num_withdrawals = None ):
313
308
if num_withdrawals is None :
314
309
num_withdrawals = rng .randint (0 , spec .MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD )
315
310
316
- withdrawals_requests = []
317
-
318
- state .slot += spec .config .SHARD_COMMITTEE_PERIOD * spec .SLOTS_PER_EPOCH
319
-
320
311
current_epoch = spec .get_current_epoch (state )
321
312
active_validator_indices = spec .get_active_validator_indices (state , current_epoch )
322
313
314
+ withdrawal_requests = []
323
315
for _ in range (num_withdrawals ):
324
316
if not active_validator_indices :
325
317
break
326
318
327
319
address = rng .getrandbits (160 ).to_bytes (20 , 'big' )
328
-
329
320
validator_index = rng .choice (active_validator_indices )
330
321
validator = state .validators [validator_index ]
331
322
validator_balance = state .balances [validator_index ]
332
-
333
- withdrawal_request = spec .WithdrawalRequest (
323
+ withdrawal_requests .append (spec .WithdrawalRequest (
334
324
source_address = address ,
335
325
validator_pubkey = validator .pubkey ,
336
326
amount = rng .randint (0 , validator_balance ),
337
- )
338
-
339
- withdrawals_requests .append (withdrawal_request )
327
+ ))
340
328
341
- return withdrawals_requests
329
+ return withdrawal_requests
342
330
343
331
344
- def get_random_consolidations_requests (spec , state , rng , num_consolidations = None ):
332
+ def get_random_consolidation_requests (spec , state , rng , num_consolidations = None ):
345
333
if num_consolidations is None :
346
334
num_consolidations = rng .randint (0 , spec .MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD )
347
335
348
- consolidations_requests = []
349
-
350
- state .slot += spec .config .SHARD_COMMITTEE_PERIOD * spec .SLOTS_PER_EPOCH
351
-
352
336
current_epoch = spec .get_current_epoch (state )
353
337
active_validator_indices = spec .get_active_validator_indices (state , current_epoch )
354
338
339
+ consolidation_requests = []
355
340
for _ in range (num_consolidations ):
356
341
source_address = rng .getrandbits (160 ).to_bytes (20 , 'big' )
357
-
358
342
source_index = rng .choice (active_validator_indices )
359
343
target_index = rng .choice (active_validator_indices )
360
-
361
344
source_validator = state .validators [source_index ]
362
345
target_validator = state .validators [target_index ]
363
-
364
- consolidation_request = spec .ConsolidationRequest (
346
+ consolidation_requests .append (spec .ConsolidationRequest (
365
347
source_address = source_address ,
366
348
source_pubkey = source_validator .pubkey ,
367
349
target_pubkey = target_validator .pubkey ,
368
- )
369
-
370
- consolidations_requests .append (consolidation_request )
350
+ ))
371
351
372
- return consolidations_requests
352
+ return consolidation_requests
0 commit comments