Skip to content

Conversation

terencechain
Copy link
Contributor

No description provided.

This comment was marked as spam.

This comment was marked as duplicate.

@jtraglia jtraglia added the eip7732 ePBS label Jul 29, 2025
Comment on lines 158 to 161
if is_post_eip7732(spec):
assert len(expected_withdrawals_result[0]) == 0
else:
assert len(expected_withdrawals_result) == 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the else condition necessary if we use @with_eip7732_and_later?

Comment on lines 296 to 297
else:
expected_withdrawals = spec.get_expected_withdrawals(state)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing with this else block. We don't need to check is_post_eip7732.

Comment on lines 300 to 304
# Verify priority ordering: builder -> pending -> sweep
assert len(expected_withdrawals) == 3
assert expected_withdrawals[0].validator_index == builder_index # Builder first
assert expected_withdrawals[1].validator_index == pending_index # Pending second
assert expected_withdrawals[2].validator_index == sweep_index # Sweep third
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming here is a bit confusing. Maybe these would be better:

  • Builder payments
  • Pending partial withdrawals
  • Exit/excess withdrawals


@with_eip7732_and_later
@spec_state_test
def test_maximum_withdrawals_per_payload_limit(spec, state):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also test for:

  • There are more than MAX_WITHDRAWALS_PER_PAYLOAD builder payments and the pending partial withdrawals queue is not empty. Assert that the builder_pending_withdrawals queue is still not empty. Assert that none of the other withdrawals were processed.
  • No builder payments, MAX_WITHDRAWALS_PER_PAYLOAD pending partial withdrawals, some sweep withdrawals. There would be sweep withdrawals because of MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP.
  • No builder payments, no pending partial withdrawals, MAX_WITHDRAWALS_PER_PAYLOAD sweep withdrawals.

Comment on lines 354 to 360
# Add multiple pending withdrawals
for i in range(3):
prepare_pending_withdrawal(spec, state, i)

# EIP-7732 limits pending withdrawals to min(MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP, MAX_WITHDRAWALS_PER_PAYLOAD - 1)
# In minimal config: min(2, 4-1) = 2
expected_withdrawals = min(3, spec.MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add enough pending partial withdrawals for this to test the mainnet value (8) too. So maybe queue MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP withdrawals and set num_expected to that too?

Test withdrawal processing with validator not yet active.
"""
set_parent_block_full(spec, state)
validator_index = min(len(state.validators) // 2, spec.MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP - 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this so complicated?

Comment on lines 443 to 445
validator_index = min(
len(state.validators) // 2 + 1, spec.MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP - 1
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here? Why not just index 0?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do this in a follow up PR, but there are some missing tests that I would like to see here. We need to ensure that builders can perform the full range of "regular" withdrawals too. Eg a builder can do partial withdrawals.

set_parent_block_full(spec, state)
current_epoch = spec.get_current_epoch(state)
set_validator_fully_withdrawable(spec, state, 3, current_epoch)
state.validators[3].effective_balance = 10000000000
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer we use MIN_ACTIVATION_BALANCE here.

current_epoch = spec.get_current_epoch(state)
set_validator_fully_withdrawable(spec, state, 4, current_epoch)
state.validators[4].effective_balance = 0
state.balances[4] = 100000000
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer we use MIN_ACTIVATION_BALANCE here too.

@terencechain
Copy link
Contributor Author

thanks @jtraglia , I think I addressed everything in 63ebc37

@jtraglia
Copy link
Member

jtraglia commented Aug 4, 2025

thanks @jtraglia , I think I addressed everything in 63ebc37

Thank you. Will review these changes in a bit. We'll need @potuz to review too.

PS: The CI runners are currently broken. I've asked EF devops to look into it.

@jtraglia
Copy link
Member

jtraglia commented Aug 4, 2025

@terencechain currently failing lint checks.

@terencechain terencechain force-pushed the process-wd-tests branch 3 times, most recently from 1870941 to f07705d Compare August 4, 2025 18:37
@terencechain terencechain marked this pull request as draft August 20, 2025 22:59
@jtraglia jtraglia changed the title eip7732: add tests for process_withdrawals block processing eip7732: add tests for process_withdrawals block processing Sep 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants