Skip to content

Commit

Permalink
fix random withdrawals
Browse files Browse the repository at this point in the history
  • Loading branch information
KatyaRyazantseva committed Dec 19, 2024
1 parent e9c9a0a commit 05a323e
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions tests/core/pyspec/eth2spec/test/helpers/execution_payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
from eth2spec.test.helpers.keys import privkeys
from eth2spec.utils.ssz.ssz_impl import hash_tree_root
from eth2spec.debug.random_value import get_random_bytes_list
from eth2spec.test.helpers.withdrawals import (
get_expected_withdrawals,
get_random_withdrawal,
)
from eth2spec.test.helpers.withdrawals import get_expected_withdrawals
from eth2spec.test.helpers.forks import (
is_post_capella,
is_post_deneb,
Expand Down Expand Up @@ -369,6 +366,7 @@ def build_empty_execution_payload(spec, state, randao_mix=None):


def build_randomized_execution_payload(spec, state, rng):
from eth2spec.test.helpers.random import exit_random_validators
execution_payload = build_empty_execution_payload(spec, state)
execution_payload.fee_recipient = spec.ExecutionAddress(get_random_bytes_list(rng, 20))
execution_payload.state_root = spec.Bytes32(get_random_bytes_list(rng, 32))
Expand All @@ -390,12 +388,19 @@ def build_randomized_execution_payload(spec, state, rng):
get_random_tx(rng)
for _ in range(num_transactions)
]

if is_post_capella(spec):
num_withdrawals = rng.randint(0, spec.MAX_WITHDRAWALS_PER_PAYLOAD)
execution_payload.withdrawals = [
get_random_withdrawal(spec, state, rng)
for _ in range(num_withdrawals)
]
current_epoch = spec.get_current_epoch(state)
exit_random_validators(
spec,
state,
rng,
exit_epoch=current_epoch,
withdrawable_epoch=current_epoch,
from_epoch=current_epoch
)
execution_payload.withdrawals = get_expected_withdrawals(spec, state)

if is_post_deneb(spec):
execution_payload.blob_gas_used = rng.randint(0, int(10e10))
execution_payload.excess_blob_gas = rng.randint(0, int(10e10))
Expand Down

0 comments on commit 05a323e

Please sign in to comment.