Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix EIP-7251 tests #3656

Merged
merged 21 commits into from
Apr 16, 2024
Merged

Fix EIP-7251 tests #3656

merged 21 commits into from
Apr 16, 2024

Conversation

ralexstokes
Copy link
Member

@ralexstokes ralexstokes commented Apr 6, 2024

supersedes #3648.

spec fixes pulled out into #3657. will get that merged and rebase this to just the test fixes (may need to discuss some of them..)

@ralexstokes ralexstokes force-pushed the fix-7251-tests branch 10 times, most recently from 68b0aeb to ebf1502 Compare April 6, 2024 23:06
@ralexstokes ralexstokes force-pushed the fix-7251-tests branch 3 times, most recently from a593987 to 56f087f Compare April 6, 2024 23:44
@ralexstokes ralexstokes force-pushed the fix-7251-tests branch 2 times, most recently from 5d6ffbd to 5447aa9 Compare April 8, 2024 02:37
@ralexstokes ralexstokes force-pushed the fix-7251-tests branch 7 times, most recently from 6f4baab to 2085bef Compare April 8, 2024 17:58
@ralexstokes ralexstokes force-pushed the fix-7251-tests branch 3 times, most recently from 1d1b8ae to 57a6032 Compare April 8, 2024 19:13
current_epoch = spec.get_current_epoch(state)

source_index = spec.get_active_validator_indices(state, current_epoch)[0]
# Set source balance higher than consolidation churn limit
state.balances[source_index] = consolidation_churn_limit + 1
state.validators[source_index].effective_balance = 2 * consolidation_churn_limit
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
state.validators[source_index].effective_balance = 2 * consolidation_churn_limit
state.validators[source_index].effective_balance = consolidation_churn_limit + spec.EFFECTIVE_BALANCE_INCREMENT

I'd maybe do this instead, just to make it easier to interpret what happens. Here one sees the effective balance being 2x the churn limit, and it can be confusing why then expected_exit_epoch only gets a +1 instead of +2

@ralexstokes
Copy link
Member Author

need to review but likely want to merge this in first: ralexstokes#3

Copy link
Contributor

@hwwhww hwwhww left a comment

Choose a reason for hiding this comment

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

well done 👍

note that some EIP-7251 results don't align with the testing goal/expections we had in the old tests. we'll need to have another scan of the missing edge cases.


def get_expected_withdrawals(spec, state):
if is_post_eip7251(spec):
withdrawals, _ = spec.get_expected_withdrawals(state)
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm, not suggesting changing in this PR, but ideally, it could be renamed into a new function name in Electra as the return values changed. e.g., get_expected_withdrawals_and_partial_withdrawals_count. kinda long though.

Copy link
Member Author

@ralexstokes ralexstokes Apr 15, 2024

Choose a reason for hiding this comment

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

yeah, if we look at how it is used, we could instead just pop() from the list and leave this function alone

update: remerkleable's pop doesn't return the value, just delete's from the list, so moving to this strategy would require changes to the underlying ssz library...

Comment on lines +362 to +366
# ensure we go through an epoch transition, to account for post-EIP-7251 behavior
block_in_next_epoch = build_empty_block(spec, state, slot=state.slot + spec.SLOTS_PER_EPOCH)
signed_block_in_next_epoch = state_transition_and_sign_block(spec, state, block_in_next_epoch)

yield 'blocks', [signed_block, signed_block_in_next_epoch]
Copy link
Contributor

Choose a reason for hiding this comment

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

should it be only with if is_post_eip7251: ... condition to distinguish the post-EIP-7251 behavior?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think its fine as extending the blocks is backwards-compatible with the capella and deneb behavior

tests/core/pyspec/eth2spec/test/helpers/deposits.py Outdated Show resolved Hide resolved
@ralexstokes ralexstokes merged commit 77ec547 into ethereum:dev Apr 16, 2024
30 checks passed
@ralexstokes ralexstokes deleted the fix-7251-tests branch April 16, 2024 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants