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

Add a test with a consolidation and deposit request in the same block #4113

Closed
wants to merge 2 commits into from

Conversation

nethoxa
Copy link

@nethoxa nethoxa commented Jan 30, 2025

This PR adds a test to check that the effective balance of a validator does not change if such a validator on the EL sent two requests on the same block, namely a deposit and a consolidation request (which in theory would allow him to increase his effective balance). However, this is not the case, so the test proves this behavior.

@jtraglia jtraglia changed the title Added a test to check consolidation and deposits requests on the same block Add a test with a consolidation and deposit request in the same block Jan 30, 2025
Copy link
Member

@jtraglia jtraglia left a comment

Choose a reason for hiding this comment

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

a test to check that the effective balance of a validator does not change if such a validator

It does change though 😄 the source validator's excess balance (mod 1 ETH) becomes its effective balance.

This is a useful new test because it ensures deposits are processed before consolidations. Thank you!

# 2) Create deposit request
deposit = prepare_pending_deposit(
spec, validator_index=source_index,
amount=spec.MIN_ACTIVATION_BALANCE, signed=True
Copy link
Member

Choose a reason for hiding this comment

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

I suggest changing the deposit amount to spec.EFFECTIVE_BALANCE_INCREMENT so that we can see that the source validator's new effective balance has changed.

Comment on lines +174 to +176
# 5) Check that balance increased but effective balance remained unchanged
assert state.balances[source_index] == spec.MIN_ACTIVATION_BALANCE
assert state.validators[source_index].effective_balance == spec.MIN_ACTIVATION_BALANCE
Copy link
Member

Choose a reason for hiding this comment

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

Then update this comment & these asserts.

@jtraglia
Copy link
Member

jtraglia commented Jan 30, 2025

Hmm after further review, this test isn't setup quite right. It's sort of an impossible situation currently. Because we didn't run process_consolidation_request, the source validator's exit_epoch and withdrawable_epoch aren't correct. In reality, pending consolidations are only processed after the source validator becomes withdrawable, which would be at least MIN_VALIDATOR_WITHDRAWABILITY_DELAY epochs after the consolidation request is processed.

@nethoxa nethoxa closed this Feb 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants